summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/loadparm.h160
-rw-r--r--source3/params.h45
-rw-r--r--source3/pcap.h35
-rw-r--r--source3/reply.h60
-rw-r--r--source3/smbpass.h50
-rw-r--r--source3/sockspy.c302
6 files changed, 652 insertions, 0 deletions
diff --git a/source3/loadparm.h b/source3/loadparm.h
new file mode 100644
index 0000000000..513dbcd636
--- /dev/null
+++ b/source3/loadparm.h
@@ -0,0 +1,160 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Parameter loading functions
+ Copyright (C) Karl Auer 1993, 1994
+
+ Extensively modified by Andrew Tridgell
+
+ 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.
+*/
+
+/*
+ *
+ * Prototypes etc for loadparm.c.
+ *
+ */
+#ifndef _LOADPARM_H
+#define _LOADPARM_H
+
+#include "smb.h"
+
+extern BOOL lp_file_list_changed(void);
+extern void lp_killunused(BOOL (*snumused)(int ));
+extern BOOL lp_loaded(void);
+extern BOOL lp_snum_ok(int iService);
+extern BOOL lp_manglednames(int iService);
+extern char *lp_passwordserver(void);
+extern char *lp_passwd_program(void);
+extern char *lp_passwd_chat(void);
+extern char *lp_guestaccount(int iService);
+extern char *lp_printcapname(void);
+extern char *lp_lockdir(void);
+extern char *lp_logfile(void);
+extern char *lp_configfile(void);
+extern char *lp_smb_passwd_file(void);
+extern char *lp_rootdir(void);
+extern char *lp_defaultservice(void);
+extern char *lp_serverstring(void);
+extern char *lp_dfree_command(void);
+extern char *lp_msg_command(void);
+extern char *lp_workgroup(void);
+extern char *lp_domain_controller(void);
+extern char *lp_username_map(void);
+extern char *lp_hosts_equiv(void);
+extern char *lp_logon_script(void);
+extern char *lp_magicscript(int iService);
+extern char *lp_magicoutput(int iService);
+extern char *lp_mangled_map(int iService);
+char *volume_label(int snum);
+extern int lp_os_level(void);
+extern int lp_max_ttl(void);
+extern int lp_max_log_size(void);
+extern int lp_maxxmit(void);
+extern int lp_maxmux(void);
+extern int lp_mangledstack(void);
+extern BOOL lp_preferred_master(void);
+extern BOOL lp_domain_master(void);
+extern BOOL lp_domain_logons(void);
+extern BOOL lp_getwdcache(void);
+extern BOOL lp_use_rhosts(void);
+extern BOOL lp_readprediction(void);
+extern BOOL lp_readbmpx(void);
+extern BOOL lp_readraw(void);
+extern BOOL lp_writeraw(void);
+extern BOOL lp_null_passwords(void);
+extern BOOL lp_strip_dot(void);
+extern BOOL lp_encrypted_passwords(void);
+extern BOOL lp_syslog_only(void);
+extern BOOL lp_browse_list(void);
+extern int lp_numservices(void);
+extern int lp_keepalive(void);
+extern int lp_passwordlevel(void);
+extern int lp_security(void);
+extern int lp_printing(void);
+extern int lp_maxdisksize(void);
+extern int lp_lpqcachetime(void);
+extern int lp_syslog(void);
+extern int lp_deadtime(void);
+extern int lp_debuglevel(void);
+extern int lp_maxprotocol(void);
+extern int lp_maxpacket(void);
+extern char *lp_comment(int iService);
+extern char *lp_preexec(int iService);
+extern char *lp_postexec(int iService);
+extern char *lp_rootpreexec(int iService);
+extern char *lp_rootpostexec(int iService);
+extern char *lp_servicename(int iService);
+extern char *lp_pathname(int iService);
+extern char *lp_username(int iService);
+extern char *lp_invalid_users(int iService);
+extern char *lp_valid_users(int iService);
+extern char *lp_admin_users(int iService);
+extern char *lp_printcommand(int iService);
+extern char *lp_lpqcommand(int iService);
+extern char *lp_lprmcommand(int iService);
+extern char *lp_lppausecommand(int iService);
+extern char *lp_lpresumecommand(int iService);
+extern char *lp_printername(int iService);
+extern char *lp_hostsallow(int iService);
+extern char *lp_hostsdeny(int iService);
+extern char *lp_dontdescend(int iService);
+extern char *lp_force_user(int iService);
+extern char *lp_force_group(int iService);
+extern char *lp_readlist(int iService);
+extern char *lp_writelist(int iService);
+extern BOOL lp_alternate_permissions(int iService);
+extern BOOL lp_revalidate(int iService);
+extern BOOL lp_status(int iService);
+extern BOOL lp_hide_dot_files(int iService);
+extern BOOL lp_browseable(int iService);
+extern BOOL lp_widelinks(int iService);
+extern BOOL lp_syncalways(int iService);
+extern BOOL lp_readonly(int iService);
+extern BOOL lp_no_set_dir(int iService);
+extern BOOL lp_guest_ok(int iService);
+extern BOOL lp_guest_only(int iService);
+extern BOOL lp_print_ok(int iService);
+extern BOOL lp_postscript(int iService);
+extern BOOL lp_map_hidden(int iService);
+extern BOOL lp_map_archive(int iService);
+extern BOOL lp_locking(int iService);
+extern BOOL lp_strict_locking(int iService);
+extern BOOL lp_share_modes(int iService);
+extern BOOL lp_onlyuser(int iService);
+extern BOOL lp_map_system(int iService);
+extern BOOL lp_casesensitive(int iService);
+extern BOOL lp_casemangle(int iService);
+extern BOOL lp_preservecase(int iService);
+extern BOOL lp_shortpreservecase(int iService);
+extern BOOL lp_load(char *pszFname,BOOL global_only);
+extern void lp_dump(void);
+extern int lp_servicenumber(char *pszServiceName);
+extern BOOL lp_add_home(char *pszHomename,
+ int iDefaultService, char *pszHomedir);
+extern int lp_add_service(char *service, int iDefaultService);
+extern BOOL lp_add_printer(char *pszPrintername, int iDefaultService);
+extern BOOL lp_readonly(int iService);
+extern int lp_create_mode(int iService);
+extern int lp_minprintspace(int iService);
+extern int lp_defaultcase(int iService);
+extern char lp_magicchar(int iService);
+extern int lp_max_connections(int iService);
+extern BOOL lp_add_home(char *pservice,int ifrom,char *phome);
+extern char *lp_string(char *s);
+char *my_workgroup(void);
+
+#endif
+
diff --git a/source3/params.h b/source3/params.h
new file mode 100644
index 0000000000..253eaa4e7a
--- /dev/null
+++ b/source3/params.h
@@ -0,0 +1,45 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Parameter loading utilities
+ Copyright (C) Karl Auer 1993, 1994
+
+ 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.
+*/
+
+/**************************************************************************
+PARAMS.H
+
+Copyright (C) 1990, 1991, 1992 Karl Auer
+
+Prototypes and definitions for PARAMS.C.
+**************************************************************************/
+#ifndef _PARAMS_H
+#define _PARAMS_H
+
+#include <stdio.h>
+#include "smb.h"
+
+typedef BOOL (* PM_PARMFUNC)(char *pszParmName, char *pszParmValue);
+typedef BOOL (* PM_SECFUNC)(char *pszSectionName);
+
+#define PM_NOFILE 1
+#define PM_NOFILENAME 2
+#define PM_FILEERROR 3
+
+extern BOOL pm_process(char *pszFileName, PM_SECFUNC sfunc, PM_PARMFUNC pfunc);
+
+#endif
+
diff --git a/source3/pcap.h b/source3/pcap.h
new file mode 100644
index 0000000000..89ab359af6
--- /dev/null
+++ b/source3/pcap.h
@@ -0,0 +1,35 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ printcap parsing
+ Copyright (C) Karl Auer 1993, 1994
+
+ 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.
+*/
+
+/*
+ *
+ * Prototypes etc for pcap.c.
+ *
+ */
+#ifndef _PCAP_H
+#define _PCAP_H
+
+#include "smb.h"
+
+extern BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname);
+extern void pcap_printer_fn(void (*fn)());
+
+#endif
diff --git a/source3/reply.h b/source3/reply.h
new file mode 100644
index 0000000000..f88229436f
--- /dev/null
+++ b/source3/reply.h
@@ -0,0 +1,60 @@
+int reply_special(char *inbuf,char *outbuf);
+int reply_corep(char *outbuf);
+int reply_coreplus(char *outbuf);
+int reply_nt1(char *outbuf);
+int reply_lanman1(char *outbuf);
+int reply_lanman2(char *outbuf);
+int reply_tcon(char *inbuf,char *outbuf);
+int reply_tcon_and_X(char *inbuf,char *outbuf,int length,int bufsize);
+int reply_unknown(char *inbuf,char *outbuf);
+int reply_ioctl(char *inbuf,char *outbuf);
+int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize);
+int reply_chkpth(char *inbuf,char *outbuf);
+int reply_getatr(char *inbuf,char *outbuf);
+int reply_setatr(char *inbuf,char *outbuf);
+int reply_dskattr(char *inbuf,char *outbuf);
+int reply_search(char *inbuf,char *outbuf);
+int reply_fclose(char *inbuf,char *outbuf);
+int reply_open(char *inbuf,char *outbuf);
+int reply_open_and_X(char *inbuf,char *outbuf,int length,int bufsize);
+int reply_ulogoffX(char *inbuf,char *outbuf,int length,int bufsize);
+int reply_mknew(char *inbuf,char *outbuf);
+int reply_ctemp(char *inbuf,char *outbuf);
+int reply_unlink(char *inbuf,char *outbuf);
+int reply_readbraw(char *inbuf, char *outbuf);
+int reply_lockread(char *inbuf,char *outbuf);
+int reply_read(char *inbuf,char *outbuf);
+int reply_read_and_X(char *inbuf,char *outbuf,int length,int bufsize);
+int reply_writebraw(char *inbuf,char *outbuf);
+int reply_writeunlock(char *inbuf,char *outbuf);
+int reply_write(char *inbuf,char *outbuf,int dum1,int dum2);
+int reply_write_and_X(char *inbuf,char *outbuf,int length,int bufsize);
+int reply_lseek(char *inbuf,char *outbuf);
+int reply_flush(char *inbuf,char *outbuf);
+int reply_exit(char *inbuf,char *outbuf);
+int reply_close(char *inbuf,char *outbuf);
+int reply_writeclose(char *inbuf,char *outbuf);
+int reply_lock(char *inbuf,char *outbuf);
+int reply_unlock(char *inbuf,char *outbuf);
+int reply_tdis(char *inbuf,char *outbuf);
+int reply_echo(char *inbuf,char *outbuf);
+int reply_printopen(char *inbuf,char *outbuf);
+int reply_printclose(char *inbuf,char *outbuf);
+int reply_printqueue(char *inbuf,char *outbuf);
+int reply_printwrite(char *inbuf,char *outbuf);
+int reply_mkdir(char *inbuf,char *outbuf);
+int reply_rmdir(char *inbuf,char *outbuf);
+int reply_mv(char *inbuf,char *outbuf);
+int reply_copy(char *inbuf,char *outbuf);
+int reply_setdir(char *inbuf,char *outbuf);
+int reply_lockingX(char *inbuf,char *outbuf,int length,int bufsize);
+int reply_readbmpx(char *inbuf,char *outbuf,int length,int bufsize);
+int reply_writebmpx(char *inbuf,char *outbuf);
+int reply_setattrE(char *inbuf,char *outbuf);
+int reply_getattrE(char *inbuf,char *outbuf);
+int reply_writebs(char *inbuf,char *outbuf);
+int reply_sends(char *inbuf,char *outbuf);
+int reply_sendstrt(char *inbuf,char *outbuf);
+int reply_sendend(char *inbuf,char *outbuf);
+int reply_sendtxt(char *inbuf,char *outbuf);
+int reply_transs2(char *inbuf,char *outbuf,int length,int bufsize);
diff --git a/source3/smbpass.h b/source3/smbpass.h
new file mode 100644
index 0000000000..6ddca0b92d
--- /dev/null
+++ b/source3/smbpass.h
@@ -0,0 +1,50 @@
+#ifndef _SMBPASS_H_
+#define _SMBPASS_H_
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ SMB parameters and setup
+ Copyright (C) Jeremy Allison 1995
+
+ 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.
+*/
+
+struct smb_passwd {
+ int smb_userid;
+ char *smb_name;
+ unsigned char *smb_passwd; /* Null if no password */
+ unsigned char *smb_nt_passwd; /* Null if no password */
+ /* Other fields / flags may be added later */
+};
+
+/* Return a smb_passwd struct given a user name, 0 if fails. */
+struct smb_passwd *get_smbpwnam(char *user);
+
+#ifndef uchar
+#define uchar unsigned char
+#endif
+
+/* SMB Encryption functions. */
+void str_to_key(unsigned char *str,unsigned char *key);
+void E_P16(uchar *p14,uchar *p16);
+void E_P24(unsigned char *p21, unsigned char *c8, unsigned char *p24);
+void E_md4hash(uchar *passwd,uchar *p16);
+void SMBencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24);
+void SMB_nt_encrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24);
+
+/* Password file lock/unlock routines */
+int pw_file_lock(char *name, int type, int secs);
+int pw_file_unlock(int fd);
+#endif
diff --git a/source3/sockspy.c b/source3/sockspy.c
new file mode 100644
index 0000000000..806b737915
--- /dev/null
+++ b/source3/sockspy.c
@@ -0,0 +1,302 @@
+/*
+ USAGE
+ sockspy desthost destservice
+
+You install this program in /etc/inetd.conf and /etc/services
+
+For example I have used these entries:
+
+/etc/services:
+spy 8001/tcp spy port
+
+/etc/inetd.conf:
+spy stream tcp nowait tridge /usr/local/smb/sockspy sockspy fjall netbios-ssn
+
+This means any connection to port 8001 will be redirected to
+netbios-ssn on fjall. By playing with these parameters you can easily
+spy on most of the tcp protocols. All packets traversing the link will
+be captured.
+
+NOTE: This program is totally unsupported. I haven't used it for 2
+years, and don't intend to fix the obvious bugs/limitations. I will,
+however, accept contributed patches - or even a total rewrite :-)
+*/
+
+#include <stdio.h>
+#include <strings.h>
+#include <sys/types.h>
+#include <sys/dir.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <netinet/in.h>
+#include <netdb.h>
+
+#include <signal.h>
+
+#include <errno.h>
+#include <sysexits.h>
+
+int trans_num = 0;
+
+#ifndef LOGIN
+#define LOGIN "/tmp/spy.in"
+#endif
+
+#ifndef LOGOUT
+#define LOGOUT "/tmp/spy.out"
+#endif
+
+#ifndef LOGCMD
+#define LOGCMD "/tmp/spy.cmd"
+#endif
+
+FILE *cmd = NULL;
+FILE *login = NULL;
+FILE *logout = NULL;
+
+#define STREQL(a, b) (strcmp(a, b) == 0)
+#define NIL (0)
+
+char DestHost[256]; /* Remote system to connect to */
+char DestObj[256]; /* Remote object/service to connect to */
+
+/* Signal handler for SIGPIPE (write on a disconnected socket) */
+abort()
+{
+ if (cmd)
+ {
+ fprintf(cmd,"writing to disconnected socket!\n");
+ fflush(cmd);
+ }
+ exit(1);
+}
+
+
+main(argc, argv)
+int argc; /* # of command line arguments */
+char *argv[]; /* the command line arguments */
+{
+ int client, /* Socket connected to client */
+ server; /* Socket to use for server */
+
+ trans_num = 0;
+#ifndef NOLOG
+ login = fopen(LOGIN,"w");
+ logout = fopen(LOGOUT,"w");
+ cmd = fopen(LOGCMD,"w");
+#endif
+
+ if (cmd)
+ {
+ fprintf(cmd,"Started server\n");
+ fflush(cmd);
+ }
+
+ /* Check usage */
+ if(argc != 3)
+ return;
+
+ strcpy(DestHost,argv[1]);
+ strcpy(DestObj,argv[2]);
+
+ /* Time to attempt the connection */
+ server = inet_conn(DestHost, DestObj);
+
+ if( server < 0 ) {
+ exit(EX_CANTCREAT);
+ }
+
+ /* Just to make the code more readable */
+ client = 0;
+
+ /* We will abort gracefully when the client or remote system
+ goes away */
+ signal(SIGPIPE, abort);
+
+ /* Now just go and move raw data between client and
+ remote system */
+ dowork(client, server);
+ /* ... NEVER RETURNS ... */
+}
+
+dowork(client, server)
+ int client, server;
+{
+
+ /* select(2) masks for client and remote */
+ int ClientMask, ServerMask;
+
+ /* Combined ClientMask and ServerMask */
+ int ReadMask;
+
+ /* Initialize select(2) masks */
+ ClientMask = 1<<client;
+ ServerMask = 1<<server;
+
+ ReadMask = ClientMask | ServerMask;
+
+ /* Now move raw data for the rest of our life between
+ client and remote */
+ for( ; ; ) {
+ /* Local Variables */
+ int SelectReadMask;/* select(2) mask modifiable by select(2) */
+ int nready; /* status return from select(2) */
+
+ do {
+ /* Intialize select(2) mask everytime
+ as select(2) always modifies it */
+ SelectReadMask = ReadMask;
+
+ /* Wait for data to be present to be moved */
+ errno = 0;
+ nready = select(32,&SelectReadMask,(int *)0,(int *)0,NIL);
+ } while( nready < 0 && errno == EINTR );
+
+ /* select(2) failed, shouldn't happen. Exit abnormally */
+ if( nready < 0 )
+ exit(EX_SOFTWARE);
+
+ /* Favor the client (for no particular reason)
+ if s/he is has data */
+ if( SelectReadMask & ClientMask )
+ {
+ if (cmd)
+ fprintf(cmd,"client %d\n",nready);
+ xfer(client, server,login);
+ }
+
+ /* Then check on the other guy */
+ if( SelectReadMask & ServerMask )
+ {
+ if (cmd)
+ fprintf(cmd,"server %d\n",nready);
+ xfer(server, client,logout);
+ }
+ }
+
+ /* NEVER REACHED */
+}
+
+#define BUFSIZE 20000 /* Max bytes to move at a time */
+
+xfer(from, to,file)
+ int from, to; /* Move data from "from" to "to" */
+ FILE *file;
+{
+ static char buf[BUFSIZE]; /* Buffer data to be moved */
+ int nready; /* # bytes readable */
+ int got; /* # bytes actually being moved */
+ int ret;
+
+ /* Query the system how many bytes are ready to be read */
+ ioctl(from, FIONREAD, &nready);
+
+ if (cmd)
+ fprintf(cmd,"nready = %d\n",nready);
+
+ /* Only try to get the smaller of nready and BUFSIZE */
+ got = read(from, buf, nready < BUFSIZE ? nready : BUFSIZE);
+
+ /* Zero bytes returned indicates end of stream, exit gracefully */
+ if( got == 0 )
+ {
+ if (cmd)
+ {
+ fprintf(cmd,"read 0 bytes exiting\n");
+ fflush(cmd);
+ }
+ if (login)
+ fclose(login);
+ if (logout)
+ fclose(logout);
+ if (cmd)
+ fclose(cmd);
+ exit(EX_OK);
+ }
+
+
+ if (file)
+ {
+ fprintf(file,"\nTransaction %d\n",trans_num);
+ fwrite(buf,got,1,file);
+ fflush(file);
+ }
+ trans_num++;
+
+ /* Now send it accross to the other side */
+ ret = write(to, buf, got);
+
+ if (cmd)
+ {
+ fprintf(cmd,"wrote %d\n",ret);
+ if (ret < 0)
+ fprintf(cmd,"error = %s\n",strerror(errno));
+ }
+}
+
+int
+inet_conn(host, port)
+ char *host;
+ char *port;
+{
+ /* Local Vars */
+ int sock; /* Socket to use for the connection */
+ struct hostent *hostent; /* Destination host entry */
+ struct servent *servent; /* Destination service entry */
+ struct sockaddr_in addr; /* Formated destination for connect */
+
+ /* Fetch the requested host and service entries */
+ hostent = gethostbyname(host);
+ if (isdigit(*port))
+ servent = getservbyport(80, "tcp");
+ else
+ servent = getservbyname(port, "tcp");
+
+
+ if (cmd)
+ {
+ fprintf(cmd,"inet_conn %s %s\n",host,port);
+
+ if (servent == NULL)
+ fprintf(cmd,"servent is NIL\n");
+ if (hostent == NULL)
+ fprintf(cmd,"hostent is NIL\n");
+ if (hostent->h_addrtype != AF_INET)
+ fprintf(cmd,"not inet type\n");
+ fflush(cmd);
+ }
+
+
+ /* No host entry, no service entry, or host is not
+ Internet, error! */
+ if( servent == NIL ||
+ hostent == NIL ||
+ hostent->h_addrtype != AF_INET )
+ return -1;
+
+ /* Get a socket from the system to use for the connection */
+ if( (sock = socket(AF_INET, SOCK_STREAM, 0)) < 0 )
+ return -1;
+
+ /* Make sure we start with a clean address structure ... */
+ bzero(&addr, sizeof(addr));
+
+ /* ... then fill in the required fields */
+ addr.sin_family = AF_INET;
+ addr.sin_port = servent->s_port;
+ bcopy(hostent->h_addr, &addr.sin_addr, hostent->h_length);
+
+ /* Now try to connection to the destination */
+ if( connect(sock, &addr, sizeof(addr)) < 0 ) {
+ /* No go, release the socket, and then return error! */
+ close(sock);
+ return -1;
+ }
+
+ /* Success. Return the connected socket descriptor */
+ if (cmd)
+ fprintf(cmd,"returning %d\n",sock);
+ return sock;
+}
+
+