diff options
author | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 15:28:53 -0500 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 15:28:53 -0500 |
commit | 65229e966119f0b1537d258854a54105f32ae399 (patch) | |
tree | c6be94324703d914228290a8354021c2691f3ebe /examples | |
parent | 95e77b14b5440a9ced8fdf6dc803b90c9518b8e0 (diff) | |
download | samba-65229e966119f0b1537d258854a54105f32ae399.tar.gz |
[GLUE] Rsync SAMBA_3_0 SVN r25598 in order to create the v3-0-test branch.samba-misc-tags/initial-v3-0-test
Diffstat (limited to 'examples')
-rw-r--r-- | examples/LDAP/samba.schema | 9 | ||||
-rw-r--r-- | examples/VFS/Makefile.in | 2 | ||||
-rw-r--r-- | examples/VFS/configure.in | 11 | ||||
-rw-r--r-- | examples/VFS/skel_opaque.c | 14 | ||||
-rw-r--r-- | examples/VFS/skel_transparent.c | 10 | ||||
-rw-r--r-- | examples/libsmbclient/Makefile | 10 | ||||
-rwxr-xr-x | examples/misc/adssearch.pl | 4 | ||||
-rw-r--r-- | examples/pam_winbind/pam_winbind.conf | 9 | ||||
-rw-r--r-- | examples/perfcounter/Makefile | 13 | ||||
-rw-r--r-- | examples/perfcounter/perf_writer_util.c | 8 | ||||
-rwxr-xr-x | examples/scripts/users_and_groups/adduserstogroups.pl | 167 | ||||
-rwxr-xr-x | examples/scripts/users_and_groups/createdomobj.pl | 158 |
12 files changed, 31 insertions, 384 deletions
diff --git a/examples/LDAP/samba.schema b/examples/LDAP/samba.schema index 31a7a67b8ed..549a7088623 100644 --- a/examples/LDAP/samba.schema +++ b/examples/LDAP/samba.schema @@ -501,15 +501,6 @@ objectclass ( 1.3.6.1.4.1.7165.2.2.14 NAME 'sambaTrustPassword' SUP top STRUCTUR MAY ( sambaSID $ sambaPwdLastSet )) ## -## Trust password for trusted domains -## (to be stored beneath the trusting sambaDomain object in the DIT) -## -objectclass ( 1.3.6.1.4.1.7165.2.2.15 NAME 'sambaTrustedDomainPassword' SUP top STRUCTURAL - DESC 'Samba Trusted Domain Password' - MUST ( sambaDomainName $ sambaSID $ - sambaNTPassword $ sambaPwdLastSet )) - -## ## Whole-of-domain info ## objectclass ( 1.3.6.1.4.1.7165.2.2.5 NAME 'sambaDomain' SUP top STRUCTURAL diff --git a/examples/VFS/Makefile.in b/examples/VFS/Makefile.in index 4de0efd29e8..8869a4f20d3 100644 --- a/examples/VFS/Makefile.in +++ b/examples/VFS/Makefile.in @@ -12,7 +12,7 @@ FLAGS = $(CFLAGS) $(CPPFLAGS) -fPIC \ -I$(SAMBA_SOURCE)/popt \ -I$(SAMBA_SOURCE)/lib/replace \ -I$(SAMBA_SOURCE)/lib/talloc \ - -I$(SAMBA_SOURCE)/lib/tdb/include \ + -I$(SAMBA_SOURCE)/tdb/include \ -I$(SAMBA_SOURCE)/smbwrapper \ -I$(SAMBA_SOURCE)/librpc \ -I$(SAMBA_SOURCE) -I. diff --git a/examples/VFS/configure.in b/examples/VFS/configure.in index b8e10d482b8..1a0ff6bb4ca 100644 --- a/examples/VFS/configure.in +++ b/examples/VFS/configure.in @@ -5,14 +5,14 @@ dnl We must use autotools 2.53 or above AC_PREREQ(2.53) AC_INIT(Makefile.in) -AC_CONFIG_HEADER(module_config.h) +#dnl Uncomment this if you want to use your own define's too +#AC_CONFIG_HEADER(module_config.h) #dnl To make sure that didn't get #define PACKAGE_* in modules_config.h #echo "" > confdefs.h dnl Checks for programs. AC_PROG_CC AC_PROG_INSTALL -AC_CANONICAL_HOST ################################################# # Directory handling stuff to support both the @@ -313,11 +313,6 @@ if test "$enable_shared" = "yes"; then BLDSHARED="false" LDSHFLAGS="" ;; - *darwin*) - BLDSHARED="true" - LDSHFLAGS="-bundle -flat_namespace -undefined suppress" - SHLIBEXT="dylib" - ;; *) ;; esac @@ -337,7 +332,7 @@ AC_CACHE_CHECK([whether building shared libraries actually works], ac_cv_shlib_works=no # try building a trivial shared library if test "$PICSUFFIX" = "po"; then - $CC $CPPFLAGS $CFLAGS $PICFLAGS -c -o shlib.po ${srcdir-.}/../../source/tests/shlib.c && + $CC $CPPFLAGS $CFLAGS $PICFLAGS -c -o shlib.po ${srcdir-.}/tests/shlib.c && $CC $CPPFLAGS $CFLAGS `eval echo $LDSHFLAGS` -o "shlib.$SHLIBEXT" shlib.po && ac_cv_shlib_works=yes else diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c index 1ba6a9b13bd..7103d0c27b7 100644 --- a/examples/VFS/skel_opaque.c +++ b/examples/VFS/skel_opaque.c @@ -206,11 +206,6 @@ static int skel_fchown(vfs_handle_struct *handle, files_struct *fsp, int fd, uid return vfswrap_fchown(NULL, fsp, fd, uid, gid); } -static int skel_lchown(vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid) -{ - return vfswrap_lchown(NULL, path, uid, gid); -} - static int skel_chdir(vfs_handle_struct *handle, const char *path) { return vfswrap_chdir(NULL, path); @@ -295,18 +290,18 @@ static size_t skel_get_nt_acl(vfs_handle_struct *handle, files_struct *fsp, return 0; } -static NTSTATUS skel_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, int +static BOOL skel_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, int fd, uint32 security_info_sent, SEC_DESC *psd) { errno = ENOSYS; - return NT_STATUS_NOT_IMPLEMENTED; + return False; } -static NTSTATUS skel_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp, const +static BOOL skel_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp, const char *name, uint32 security_info_sent, SEC_DESC *psd) { errno = ENOSYS; - return NT_STATUS_NOT_IMPLEMENTED; + return False; } static int skel_chmod_acl(vfs_handle_struct *handle, const char *name, mode_t mode) @@ -605,7 +600,6 @@ static vfs_op_tuple skel_op_tuples[] = { {SMB_VFS_OP(skel_fchmod), SMB_VFS_OP_FCHMOD, SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(skel_chown), SMB_VFS_OP_CHOWN, SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(skel_fchown), SMB_VFS_OP_FCHOWN, SMB_VFS_LAYER_OPAQUE}, - {SMB_VFS_OP(skel_lchown), SMB_VFS_OP_LCHOWN, SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(skel_chdir), SMB_VFS_OP_CHDIR, SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(skel_getwd), SMB_VFS_OP_GETWD, SMB_VFS_LAYER_OPAQUE}, {SMB_VFS_OP(skel_ntimes), SMB_VFS_OP_NTIMES, SMB_VFS_LAYER_OPAQUE}, diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c index 746fa31736b..2efb3d54a78 100644 --- a/examples/VFS/skel_transparent.c +++ b/examples/VFS/skel_transparent.c @@ -200,11 +200,6 @@ static int skel_fchown(vfs_handle_struct *handle, files_struct *fsp, int fd, uid return SMB_VFS_NEXT_FCHOWN(handle, fsp, fd, uid, gid); } -static int skel_lchown(vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid) -{ - return SMB_VFS_NEXT_LCHOWN(handle, path, uid, gid); -} - static int skel_chdir(vfs_handle_struct *handle, const char *path) { return SMB_VFS_NEXT_CHDIR(handle, path); @@ -286,13 +281,13 @@ static size_t skel_get_nt_acl(vfs_handle_struct *handle, files_struct *fsp, return SMB_VFS_NEXT_GET_NT_ACL(handle, fsp, name, security_info, ppdesc); } -static NTSTATUS skel_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, +static BOOL skel_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, int fd, uint32 security_info_sent, SEC_DESC *psd) { return SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, fd, security_info_sent, psd); } -static NTSTATUS skel_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp, +static BOOL skel_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp, const char *name, uint32 security_info_sent, SEC_DESC *psd) { return SMB_VFS_NEXT_SET_NT_ACL(handle, fsp, name, security_info_sent, psd); @@ -566,7 +561,6 @@ static vfs_op_tuple skel_op_tuples[] = { {SMB_VFS_OP(skel_fchmod), SMB_VFS_OP_FCHMOD, SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(skel_chown), SMB_VFS_OP_CHOWN, SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(skel_fchown), SMB_VFS_OP_FCHOWN, SMB_VFS_LAYER_TRANSPARENT}, - {SMB_VFS_OP(skel_lchown), SMB_VFS_OP_LCHOWN, SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(skel_chdir), SMB_VFS_OP_CHDIR, SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(skel_getwd), SMB_VFS_OP_GETWD, SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(skel_ntimes), SMB_VFS_OP_NTIMES, SMB_VFS_LAYER_TRANSPARENT}, diff --git a/examples/libsmbclient/Makefile b/examples/libsmbclient/Makefile index d44df77b3fb..be383aea671 100644 --- a/examples/libsmbclient/Makefile +++ b/examples/libsmbclient/Makefile @@ -10,12 +10,12 @@ EXTLIB_INCL = -I/usr/include/gtk-1.2 \ DEFS = -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE CFLAGS = -O0 -g -I$(SAMBA_INCL) $(EXTLIB_INCL) $(DEFS) -LDFLAGS = -L/usr/local/samba/lib +LDFLAGS = -L/usr/local/samba/lib \ + -lldap -lkrb5 -lgssapi_krb5 #LIBSMBCLIENT = /usr/local/samba/lib/libsmbclient.so LIBSMBCLIENT = ../../source/bin/libsmbclient.a -ldl -lresolv TESTS= testsmbc \ - tree \ testacl \ testacl2 \ testbrowse \ @@ -26,6 +26,8 @@ TESTS= testsmbc \ testutime \ testread +# tree \ + all: $(TESTS) smbsh testsmbc: testsmbc.o @@ -38,11 +40,11 @@ tree: tree.o testacl: testacl.o @echo Linking testacl - $(CC) `gtk-config --cflags` $(CFLAGS) $(LDFLAGS) -o $@ $< `gtk-config --libs` $(LIBSMBCLIENT) -lpopt + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt testacl2: testacl2.o @echo Linking testacl2 - $(CC) `gtk-config --cflags` $(CFLAGS) $(LDFLAGS) -o $@ $< `gtk-config --libs` $(LIBSMBCLIENT) -lpopt + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt testbrowse: testbrowse.o @echo Linking testbrowse diff --git a/examples/misc/adssearch.pl b/examples/misc/adssearch.pl index 725140ac600..4482222934f 100755 --- a/examples/misc/adssearch.pl +++ b/examples/misc/adssearch.pl @@ -408,7 +408,6 @@ my %ads_gtype = ( "GTYPE_SECURITY_BUILTIN_LOCAL_GROUP" => 0x80000005, "GTYPE_SECURITY_DOMAIN_LOCAL_GROUP" => 0x80000004, "GTYPE_SECURITY_GLOBAL_GROUP" => 0x80000002, - "GTYPE_SECURITY_UNIVERSAL_GROUP" => 0x80000008, "GTYPE_DISTRIBUTION_GLOBAL_GROUP" => 0x00000002, "GTYPE_DISTRIBUTION_DOMAIN_LOCAL_GROUP" => 0x00000004, "GTYPE_DISTRIBUTION_UNIVERSAL_GROUP" => 0x00000008, @@ -1782,9 +1781,8 @@ sub main () { if (!$opt_notify && ($async_search->code == LDAP_REFERRAL)) { foreach my $ref ($async_search->referrals) { print "\ngot Referral: [$ref]\n"; - my ($prot, $host, $base) = split(/\/+/, $ref); $async_ldap_hd->unbind(); - $async_ldap_hd = get_ldap_hd($host, 1); + $async_ldap_hd = get_ldap_hd($ref, 1); if (do_bind($async_ldap_hd, $sasl_bind) == -1) { $async_ldap_hd->unbind(); next; diff --git a/examples/pam_winbind/pam_winbind.conf b/examples/pam_winbind/pam_winbind.conf index a9e02a833a5..ca36e2ab00a 100644 --- a/examples/pam_winbind/pam_winbind.conf +++ b/examples/pam_winbind/pam_winbind.conf @@ -9,9 +9,6 @@ # turn on debugging ;debug = no -# turn on extended PAM state debugging -;debug_state = no - # request a cached login if possible # (needs "winbind offline logon = yes" in smb.conf) ;cached_login = no @@ -27,9 +24,3 @@ # make successful authentication dependend on membership of one SID # (can also take a name) ;require_membership_of = - -# password expiry warning period in days -;warn_pwd_expire = 14 - -# omit pam conversations -;silent = no diff --git a/examples/perfcounter/Makefile b/examples/perfcounter/Makefile index e74b7361016..07bc7657c9c 100644 --- a/examples/perfcounter/Makefile +++ b/examples/perfcounter/Makefile @@ -19,20 +19,19 @@ SAMBA_SRC_DIR=../../source TDB_SRC_DIR=$(SAMBA_SRC_DIR)/tdb -CFLAGS = -g -I$(SAMBA_SRC_DIR)/include -I$(TDB_SRC_DIR)/include +CFLAGS = -g -I$(SAMBA_SRC_DIR)/include -I$(TDB_SRC_DIR) CC = gcc PROGS = perfcount -TDB_OBJ = $(TDB_SRC_DIR)/common/tdb.o $(TDB_SRC_DIR)/common/dump.o \ - $(TDB_SRC_DIR)/common/error.o $(TDB_SRC_DIR)/common/freelist.o \ - $(TDB_SRC_DIR)/common/io.o $(TDB_SRC_DIR)/common/lock.o \ - $(TDB_SRC_DIR)/common/open.o $(TDB_SRC_DIR)/common/transaction.o \ - $(TDB_SRC_DIR)/common/traverse.o +TDB_OBJ = $(TDB_SRC_DIR)/tdb.o $(TDB_SRC_DIR)/spinlock.o $(TDB_SRC_DIR)/tdbback.o PERF_WRITER_OBJ = perf_writer.o perf_writer_mem.o perf_writer_util.o perf_writer_cpu.o perf_writer_process.o perf_writer_disk.o default: $(PROGS) -perfcount: $(PERF_WRITER_OBJ) +$(TDB_OBJ): + cd $(TDB_SRC_DIR) && make + +perfcount: $(PERF_WRITER_OBJ) $(TDB_OBJ) $(CC) $(CFLAGS) -o perfcount $(PERF_WRITER_OBJ) $(TDB_OBJ) clean: diff --git a/examples/perfcounter/perf_writer_util.c b/examples/perfcounter/perf_writer_util.c index 85ef48fb602..78a99fef494 100644 --- a/examples/perfcounter/perf_writer_util.c +++ b/examples/perfcounter/perf_writer_util.c @@ -37,6 +37,10 @@ void add_key_raw(TDB_CONTEXT *db, char *keystring, void *databuf, size_t datasiz key.dsize = strlen(keystring); data.dptr = databuf; data.dsize = datasize; + fprintf(stderr, "doing insert of [%x] with key [%s] into [%s]\n", + data.dptr, + keystring, + db->name); tdb_store(db, key, data, flags); } @@ -49,6 +53,10 @@ void add_key(TDB_CONTEXT *db, char *keystring, char *datastring, int flags) key.dsize = strlen(keystring); data.dptr = datastring; data.dsize = strlen(datastring); + /* fprintf(stderr, "doing insert of [%s] with key [%s] into [%s]\n", + data.dptr, + keystring, + db->name);*/ tdb_store(db, key, data, flags); } diff --git a/examples/scripts/users_and_groups/adduserstogroups.pl b/examples/scripts/users_and_groups/adduserstogroups.pl deleted file mode 100755 index 335dad00aae..00000000000 --- a/examples/scripts/users_and_groups/adduserstogroups.pl +++ /dev/null @@ -1,167 +0,0 @@ -#!/usr/bin/perl - -# -# adduserstogroups.pl -# -# add single or continuously numbered domain users -# to a given single group or list of groups -# -# Copyright (C) Michael Adam <obnox@samba.org> 2007 -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the Free -# Software Foundation; either version 2 of the License, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., 675 -# Mass Ave, Cambridge, MA 02139, USA. -# - -# -# WARNING: This script is still rather crude. -# - -use strict; -use Getopt::Std; - -my $net_cmd = "net"; - -# defaults: - -my $server; -my $num_members = 1; -my $startmem; # if empty, don't add numbers to member prefix -my $member_prefix; # name prefix for member -my $num_groups = 1; -my $startgroup; # if empty, don't add numbers to group prefix -my $group_prefix; # name prefix for group -my $path; # path to rpcclient command -my $net_path = $net_cmd; -my $creds; - -sub usage { - print "USAGE: $0 [-h] -S server -U user\%pass \\\n" - . "\t-m member [-s startmem] [-n nummem] \\\n" - . "\t-g group [-G stargroup] [-N numgroups] \\\n" - . "\t[-P path]\n"; -} - -# parse commandline: - -my %options = (); -getopts("U:S:m:s:n:g:G:N:P:h", \%options); - -if (exists($options{h})) { - usage(); - exit 0; -} - -if (exists($options{g})) { - $group_prefix = $options{g}; -} -else { - print "ERROR: mandatory argument '-g' missing\n"; - usage(); - exit 1; -} - -if (exists($options{U})) { - $creds = "-U $options{U}"; - if ($creds !~ '%') { - print "ERROR: you need to specify credentials in the form -U user\%pass\n"; - usage(); - exit 1; - } -} -else { - print "ERROR: mandatory argument '-U' missing\n"; - usage(); - exit 1; -} - -if (exists($options{S})) { - $server = $options{S}; -} -else { - print "ERROR: madatory argument '-S' missing\n"; - usage(); - exit 1; -} - -if (exists($options{s})) { - $startmem = $options{s}; -} - -if (exists($options{n})) { - $num_members = $options{n}; -} - -if (exists($options{m})) { - $member_prefix = $options{m}; -} -else { - print "ERROR: mandatory argument '-m' missing\n"; - usage(); - exit 1; -} - -if (exists($options{G})) { - $startgroup = $options{G}; -} - -if (exists($options{N})) { - $num_groups = $options{N}; -} - -if (exists($options{P})) { - $path = $options{p}; - $net_path = "$path/$net_cmd"; -} - -if (@ARGV) { - print "ERROR: junk on the command line ('" . join(" ", @ARGV) . "')...\n"; - usage(); - exit 1; -} - -# utility functions: - -sub do_add { - my $member_name = shift; - my $group_name = shift; - print "adding member $member_name to group $group_name\n"; - system("$net_path rpc -I $server ".$creds." group addmem $group_name $member_name"); -} - -sub add_group_loop { - my $member_name = shift; - - if ("x$startgroup" eq "x") { - do_add($member_name, $group_prefix); - } - else { - for (my $groupnum = 1; $groupnum <= $num_groups; ++$groupnum) { - do_add($member_name, - sprintf("%s%.05d", $group_prefix, $startgroup + $groupnum - 1)); - } - } -} - - -# main: - -if ("x$startmem" eq "x") { - add_group_loop($member_prefix); -} -else { - for (my $memnum = 1; $memnum <= $num_members; ++$memnum) { - add_group_loop(sprintf("%s%.05d", $member_prefix, $startmem + $memnum - 1)); - } -} - diff --git a/examples/scripts/users_and_groups/createdomobj.pl b/examples/scripts/users_and_groups/createdomobj.pl deleted file mode 100755 index 6568b216642..00000000000 --- a/examples/scripts/users_and_groups/createdomobj.pl +++ /dev/null @@ -1,158 +0,0 @@ -#!/usr/bin/perl - -# -# createdomobj.pl -# -# create single or continuously numbered domain -# users/groups/aliases via rpc -# -# Copyright (C) Michael Adam <obnox@samba.org> 2007 -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the Free -# Software Foundation; either version 2 of the License, or (at your option) -# any later version. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., 675 -# Mass Ave, Cambridge, MA 02139, USA. -# - -# -# WARNING: This script is still rather crude. -# - -use strict; -use Getopt::Std; - - -my $target_type = "group"; # what type of object to create -my $rpc_cmd = "createdom".$target_type; -my $rpccli_cmd = "rpcclient"; - -# defaults: - -my $server; -my $num_targets = 1; -my $startnum; # if empty, don't add numbers to prefix -my $prefix = $target_type; # name-prefix -my $path; # path to rpcclient command -my $rpccli_path = $rpccli_cmd; -my $creds; - -sub usage { - print "USAGE: $0 [-h] -S server -U user\%pass [-p prefix] \\\n" - . "\t[-t {alias|group|user}] [-s startnum] [-n numobjs] [-P path] \n"; -} - -# parse commandline: - -my %options = (); -getopts("U:t:S:s:n:p:P:h", \%options); - -if (exists($options{h})) { - usage(); - exit 0; -} - -if (exists($options{t})) { - $target_type = $options{t}; - if ($target_type !~ /^(alias|user|group)$/) { - print "ERROR: invalid target type given\n"; - usage(); - exit 1; - } - $rpc_cmd = "createdom".$target_type; -} - -if (exists($options{U})) { - $creds = "-U $options{U}"; - if ($creds !~ '%') { - print "ERROR: you need to specify credentials in the form -U user\%pass\n"; - usage(); - exit 1; - } -} -else { - print "ERROR: mandatory argument '-U' missing\n"; - usage(); - exit 1; -} - -if (exists($options{S})) { - $server = $options{S}; -} -else { - print "ERROR: madatory argument '-S' missing\n"; - usage(); - exit 1; -} - -if (exists($options{s})) { - $startnum = $options{s}; -} - -if (exists($options{n})) { - $num_targets = $options{n}; -} - -if (exists($options{p})) { - $prefix = $options{p}; -} - -if (exists($options{P})) { - $path = $options{p}; - $rpccli_path = "$path/$rpccli_cmd"; -} - -if (@ARGV) { - print "ERROR: junk on the command line ('" . join(" ", @ARGV) . "')...\n"; - usage(); - exit 1; -} - -# utility functions: - -sub open_rpc_pipe { - print "opening rpc pipe\n"; - open(IPC, "| $rpccli_cmd $server $creds -d0") or - die "error opening rpc pipe."; -} - -sub close_rpc_pipe { - print "closing rpc pipe\n"; - close(IPC); -} - -sub do_create { - my $target_name = shift; - print "creating $target_type $target_name\n"; - print IPC "$rpc_cmd $target_name\n"; -} - -# main: - -open_rpc_pipe(); - -if ("x$startnum" eq "x") { - do_create($prefix); -} -else { - for (my $num = 1; $num <= $num_targets; ++$num) { - do_create(sprintf "%s%.05d", $prefix, $startnum + $num - 1); - if (($num) % 500 == 0) { - printf("500 ".$target_type."s created\n"); - close_rpc_pipe(); - sleep 2; - open_rpc_pipe(); - } - } -} - -close_rpc_pipe(); - |