From 3e074dcd9664edc32d1d4947179ce90d5c4ae801 Mon Sep 17 00:00:00 2001
From: Jeremy Allison
Date: Fri, 5 Sep 1997 19:44:48 +0000
Subject: Updated code on 1.9.17 branch to add bug fixes. This is *NOT* the
same branch as the main (ie. 1.9.18) branch. Jeremy (jallison@whistle.com)
---
source/client/clientutil.c | 6 ++++
source/client/clitar.c | 3 +-
source/include/includes.h | 4 +++
source/include/proto.h | 26 ++++++++++------
source/include/smb.h | 2 ++
source/include/version.h | 2 +-
source/lib/charset.c | 2 +-
source/lib/util.c | 47 ++++++++++++++++++++++++++--
source/nameannounce.c | 2 +-
source/namepacket.c | 15 ++++++---
source/nameresp.c | 14 ++++-----
source/nameserv.c | 6 ++--
source/nameservreply.c | 78 +++++++++++++++++++++++++++-------------------
source/nmbsync.c | 2 ++
source/param/loadparm.c | 19 +++++++++--
source/printing/printing.c | 24 ++++++++++++--
source/script/mkproto.awk | 2 +-
source/smbd/ipc.c | 25 +++++++--------
source/smbd/mangle.c | 2 +-
source/smbd/password.c | 20 ++++++++++--
source/smbd/reply.c | 41 +++++++++++++++++++++---
source/smbd/server.c | 68 +++++++++++++++++++++++++++++++---------
source/smbd/trans2.c | 10 ++----
23 files changed, 308 insertions(+), 112 deletions(-)
diff --git a/source/client/clientutil.c b/source/client/clientutil.c
index 000cbba1a78..b4f0849c5fe 100644
--- a/source/client/clientutil.c
+++ b/source/client/clientutil.c
@@ -428,6 +428,12 @@ BOOL cli_send_login(char *inbuf, char *outbuf, BOOL start_session, BOOL use_setu
else
pass = (char *)getpass("Password: ");
+ if(pass == NULL)
+ {
+ DEBUG(0, ("cli_send_login : no password available - logon failed.\n"));
+ return False;
+ }
+
if (Protocol >= PROTOCOL_LANMAN1 && use_setup)
{
fstring pword;
diff --git a/source/client/clitar.c b/source/client/clitar.c
index f70e639e905..d5bca8c5bbb 100644
--- a/source/client/clitar.c
+++ b/source/client/clitar.c
@@ -376,8 +376,7 @@ Compare two strings in a slash insensitive way, allowing s1 to match s2
if s1 is an "initial" string (up to directory marker). Thus, if s2 is
a file in any subdirectory of s1, declare a match.
***************************************************************************/
-static
-int strslashcmp(char *s1, char *s2)
+static int strslashcmp(char *s1, char *s2)
{
char *s1_0=s1;
diff --git a/source/include/includes.h b/source/include/includes.h
index 15a5e74e469..a63f8f8597c 100644
--- a/source/include/includes.h
+++ b/source/include/includes.h
@@ -308,7 +308,9 @@ extern int innetgr (const char *, const char *, const char *, const char *);
#define USE_STATVFS
#define USE_GETCWD
#define USE_SETSID
+#ifndef REPLACE_GETPASS
#define REPLACE_GETPASS
+#endif /* REPLACE_GETPASS */
#define USE_SIGPROCMASK
#endif
@@ -459,7 +461,9 @@ char *mktemp(char *); /* No standard include */
#define NO_FSYNC
#define USE_GETCWD
#define USE_SETSID
+#ifndef REPLACE_GETPASS
#define REPLACE_GETPASS
+#endif /* REPLACE_GETPASS */
#define NO_GETRLIMIT
#endif /* CLIX */
diff --git a/source/include/proto.h b/source/include/proto.h
index 9f05e5bbffd..01afb7cad95 100644
--- a/source/include/proto.h
+++ b/source/include/proto.h
@@ -146,6 +146,7 @@ char *lp_wins_server(void);
char *lp_interfaces(void);
char *lp_socket_address(void);
char *lp_nis_home_map_name(void);
+char *lp_announce_version(void);
char *lp_netbios_aliases(void);
BOOL lp_dns_proxy(void);
BOOL lp_wins_support(void);
@@ -189,6 +190,7 @@ int lp_maxdisksize(void);
int lp_lpqcachetime(void);
int lp_syslog(void);
int lp_client_code_page(void);
+int lp_announce_as(void);
char *lp_preexec(int );
char *lp_postexec(int );
char *lp_rootpreexec(int );
@@ -268,10 +270,10 @@ BOOL lp_load(char *pszFname,BOOL global_only);
int lp_numservices(void);
void lp_dump(void);
int lp_servicenumber(char *pszServiceName);
+char *volume_label(int snum);
int lp_default_server_announce(void);
int lp_major_announce_version(void);
int lp_minor_announce_version(void);
-char *volume_label(int snum);
/*The following definitions come from locking.c */
@@ -460,7 +462,9 @@ void initiate_netbios_packet(uint16 *id,
int nb_flags,BOOL bcast,BOOL recurse,
struct in_addr to_ip);
void reply_netbios_packet(struct packet_struct *p1,int trn_id,
- int rcode, int rcv_code, int opcode, BOOL recurse,
+ int rcode, int rcv_code, int opcode,
+ BOOL recursion_available,
+ BOOL recursion_desired,
struct nmb_name *rr_name,int rr_type,int rr_class,int ttl,
char *data,int len);
void queue_packet(struct packet_struct *packet);
@@ -486,7 +490,6 @@ struct response_record *queue_netbios_pkt_wins(
int fd,int quest_type,enum state_type state,
char *name,int name_type,int nb_flags, time_t ttl,
int server_type, char *my_name, char *my_comment,
- BOOL bcast,BOOL recurse,
struct in_addr send_ip, struct in_addr reply_to_ip);
struct response_record *queue_netbios_packet(struct subnet_record *d,
int fd,int quest_type,enum state_type state,char *name,
@@ -613,6 +616,8 @@ int get_printqueue(int snum,int cnum,print_queue_struct **queue,
print_status_struct *status);
void del_printqueue(int cnum,int snum,int jobid);
void status_printjob(int cnum,int snum,int jobid,int status);
+int printjob_encode(int snum, int job);
+void printjob_decode(int jobid, int *snum, int *job);
/*The following definitions come from quotas.c */
@@ -620,6 +625,7 @@ BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize);
BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize);
BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize);
BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize);
+BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize);
/*The following definitions come from replace.c */
@@ -726,22 +732,22 @@ void close_cnum(int cnum, uint16 vuid);
BOOL yield_connection(int cnum,char *name,int max_connections);
BOOL claim_connection(int cnum,char *name,int max_connections,BOOL Clear);
void exit_server(char *reason);
-void standard_sub(int cnum,char *string);
+void standard_sub(int cnum,char *str);
char *smb_fn_name(int type);
int chain_reply(char *inbuf,char *outbuf,int size,int bufsize);
int construct_reply(char *inbuf,char *outbuf,int size,int bufsize);
/*The following definitions come from shmem.c */
-smb_shm_offset_t smb_shm_alloc(int size);
-smb_shm_offset_t smb_shm_addr2offset(void *addr);
-smb_shm_offset_t smb_shm_get_userdef_off(void);
BOOL smb_shm_create_hash_table( unsigned int size );
BOOL smb_shm_open( char *file_name, int size);
BOOL smb_shm_close( void );
+smb_shm_offset_t smb_shm_alloc(int size);
BOOL smb_shm_free(smb_shm_offset_t offset);
+smb_shm_offset_t smb_shm_get_userdef_off(void);
BOOL smb_shm_set_userdef_off(smb_shm_offset_t userdef_off);
void * smb_shm_offset2addr(smb_shm_offset_t offset);
+smb_shm_offset_t smb_shm_addr2offset(void *addr);
BOOL smb_shm_lock_hash_entry( unsigned int entry);
BOOL smb_shm_unlock_hash_entry( unsigned int entry );
BOOL smb_shm_get_usage(int *bytes_free,
@@ -873,7 +879,7 @@ uint32 file_size(char *file_name);
char *attrib_string(int mode);
int StrCaseCmp(const char *s, const char *t);
int StrnCaseCmp(const char *s, const char *t, int n);
-BOOL strequal(const char *s1,const char *s2);
+BOOL strequal(const char *s1, const char *s2);
BOOL strnequal(const char *s1,const char *s2,int n);
BOOL strcsequal(char *s1,char *s2);
void strlower(char *s);
@@ -951,7 +957,7 @@ BOOL zero_ip(struct in_addr ip);
void reset_globals_after_fork();
char *client_name(void);
char *client_addr(void);
-void standard_sub_basic(char *string);
+void standard_sub_basic(char *str);
BOOL same_net(struct in_addr ip1,struct in_addr ip2,struct in_addr mask);
int PutUniCode(char *dst,char *src);
struct hostent *Get_Hostbyname(char *name);
@@ -968,6 +974,8 @@ BOOL fcntl_lock(int fd,int op,uint32 offset,uint32 count,int type);
int file_lock(char *name,int timeout);
void file_unlock(int fd);
BOOL is_myname(const char *s);
+void set_remote_arch(enum remote_arch_types type);
+enum remote_arch_types get_remote_arch();
/*The following definitions come from vt_mode.c */
diff --git a/source/include/smb.h b/source/include/smb.h
index f0390230e53..b55c180f361 100644
--- a/source/include/smb.h
+++ b/source/include/smb.h
@@ -880,6 +880,8 @@ enum security_types {SEC_SHARE,SEC_USER,SEC_SERVER};
enum printing_types {PRINT_BSD,PRINT_SYSV,PRINT_AIX,PRINT_HPUX,
PRINT_QNX,PRINT_PLP,PRINT_LPRNG};
+/* Remote architectures we know about. */
+enum remote_arch_types {RA_UNKNOWN, RA_WFWG, RA_OS2, RA_WIN95, RA_WINNT, RA_SAMBA};
/* case handling */
enum case_handling {CASE_LOWER,CASE_UPPER};
diff --git a/source/include/version.h b/source/include/version.h
index 56ee92c13f3..afd20f5799d 100644
--- a/source/include/version.h
+++ b/source/include/version.h
@@ -1 +1 @@
-#define VERSION "1.9.17"
+#define VERSION "1.9.17p1"
diff --git a/source/lib/charset.c b/source/lib/charset.c
index 0bbf99e29f5..c4f67e75fb1 100644
--- a/source/lib/charset.c
+++ b/source/lib/charset.c
@@ -280,7 +280,7 @@ void codepage_initialise(int client_codepage)
if(cp)
{
- for(i = 0; (cp[i][0] != '\0') && (cp[i][1] != '\0'); i++)
+ for(i = 0; !((cp[i][0] == '\0') && (cp[i][1] == '\0')); i++)
add_dos_char(cp[i][0], (BOOL)cp[i][2], cp[i][1], (BOOL)cp[i][3]);
}
diff --git a/source/lib/util.c b/source/lib/util.c
index d78ecf2728a..7f922def7e3 100644
--- a/source/lib/util.c
+++ b/source/lib/util.c
@@ -68,6 +68,7 @@ BOOL case_mangle;
fstring remote_machine="";
fstring local_machine="";
fstring remote_arch="UNKNOWN";
+static enum remote_arch_types ra_type = RA_UNKNOWN;
fstring remote_proto="UNKNOWN";
pstring myhostname="";
pstring user_socket_options="";
@@ -91,7 +92,11 @@ void setup_logging(char *pname,BOOL interactive)
if (!interactive) {
char *p = strrchr(pname,'/');
if (p) pname = p+1;
+#ifdef LOG_DAEMON
openlog(pname, LOG_PID, LOG_DAEMON);
+#else /* LOG_DAEMON - for old systems that have no facility codes. */
+ openlog(pname, LOG_PID);
+#endif /* LOG_DAEMON */
}
#endif
if (interactive) {
@@ -3301,13 +3306,13 @@ sub strings with useful parameters
Rewritten by Stefaan A Eeckels and
Paul Rippin
********************************************************************/
-void standard_sub_basic(char *string)
+void standard_sub_basic(char *str)
{
char *s, *p;
char pidstr[10];
struct passwd *pass;
- for (s = string ; (p = strchr(s,'%')) != NULL ; s = p )
+ for (s = str ; (p = strchr(s,'%')) != NULL ; s = p )
{
switch (*(p+1))
{
@@ -3864,3 +3869,41 @@ BOOL is_myname(const char *s)
DEBUG(8, ("is_myname(\"%s\") returns %d\n", s, ret));
return(ret);
}
+
+/*******************************************************************
+set the horrid remote_arch string based on an enum.
+********************************************************************/
+void set_remote_arch(enum remote_arch_types type)
+{
+ ra_type = type;
+ switch( type )
+ {
+ case RA_WFWG:
+ strcpy(remote_arch, "WfWg");
+ return;
+ case RA_OS2:
+ strcpy(remote_arch, "OS2");
+ return;
+ case RA_WIN95:
+ strcpy(remote_arch, "Win95");
+ return;
+ case RA_WINNT:
+ strcpy(remote_arch, "WinNT");
+ return;
+ case RA_SAMBA:
+ strcpy(remote_arch,"Samba");
+ return;
+ default:
+ ra_type = RA_UNKNOWN;
+ strcpy(remote_arch, "UNKNOWN");
+ break;
+ }
+}
+
+/*******************************************************************
+ Get the remote_arch type.
+********************************************************************/
+enum remote_arch_types get_remote_arch()
+{
+ return ra_type;
+}
diff --git a/source/nameannounce.c b/source/nameannounce.c
index 2f169e9287c..684ef412581 100644
--- a/source/nameannounce.c
+++ b/source/nameannounce.c
@@ -430,7 +430,7 @@ workgroup %s\n", am_master, work->work_group));
NMB_QUERY,NAME_QUERY_DOM_SRV_CHK,
name, type, 0,0,0,
work->work_group,NULL,
- False, True, ipzero, ipzero);
+ ipzero, ipzero);
}
else if(lp_wins_support())
{
diff --git a/source/namepacket.c b/source/namepacket.c
index 086e32d9081..d60ef9f6ae2 100644
--- a/source/namepacket.c
+++ b/source/namepacket.c
@@ -183,10 +183,12 @@ void initiate_netbios_packet(uint16 *id,
/****************************************************************************
- reply to a netbios name packet
+ reply to a netbios name packet. see rfc1002.txt
****************************************************************************/
void reply_netbios_packet(struct packet_struct *p1,int trn_id,
- int rcode, int rcv_code, int opcode, BOOL recurse,
+ int rcode, int rcv_code, int opcode,
+ BOOL recursion_available,
+ BOOL recursion_desired,
struct nmb_name *rr_name,int rr_type,int rr_class,int ttl,
char *data,int len)
{
@@ -197,6 +199,11 @@ void reply_netbios_packet(struct packet_struct *p1,int trn_id,
p = *p1;
+ if (recursion_available && lp_wins_server())
+ {
+ DEBUG(0,("reply_netbios_packet: r_a not to be used when not a WINS server\n"));
+ }
+
switch (rcv_code)
{
case NMB_STATUS:
@@ -240,8 +247,8 @@ void reply_netbios_packet(struct packet_struct *p1,int trn_id,
nmb->header.opcode = opcode;
nmb->header.response = True;
nmb->header.nm_flags.bcast = False;
- nmb->header.nm_flags.recursion_available = (lp_wins_support() ? True : False );
- nmb->header.nm_flags.recursion_desired = (lp_wins_support() ? recurse : False );
+ nmb->header.nm_flags.recursion_available = recursion_available;
+ nmb->header.nm_flags.recursion_desired = recursion_desired;
nmb->header.nm_flags.trunc = False;
nmb->header.nm_flags.authoritative = True;
diff --git a/source/nameresp.c b/source/nameresp.c
index 23e70a7064d..f44171f4b67 100644
--- a/source/nameresp.c
+++ b/source/nameresp.c
@@ -117,7 +117,7 @@ static void dead_netbios_entry(struct subnet_record *d,
add_name_respond(d,n->fd,d->myip, n->response_id ,&n->name,
n->nb_flags, GET_TTL(0),
- n->reply_to_ip, False, n->reply_to_ip);
+ n->reply_to_ip, True, n->reply_to_ip);
if (!n->bcast && n->num_msgs == 0)
{
@@ -250,7 +250,6 @@ struct response_record *queue_netbios_pkt_wins(
int fd,int quest_type,enum state_type state,
char *name,int name_type,int nb_flags, time_t ttl,
int server_type, char *my_name, char *my_comment,
- BOOL bcast,BOOL recurse,
struct in_addr send_ip, struct in_addr reply_to_ip)
{
/* XXXX note: please see rfc1001.txt section 10 for details on this
@@ -260,30 +259,29 @@ struct response_record *queue_netbios_pkt_wins(
*/
if ((!lp_wins_support()) && (*lp_wins_server()))
- {
+ {
/* samba is not a WINS server, and we are using a WINS server */
struct in_addr real_wins_ip;
real_wins_ip = *interpret_addr2(lp_wins_server());
- if (!zero_ip(real_wins_ip))
+ if (!zero_ip(real_wins_ip))
{
- bcast = False;
send_ip = real_wins_ip;
}
- else
+ else
{
/* oops. smb.conf's wins server parameter MUST be a host_name
or an ip_address. */
DEBUG(0,("invalid smb.conf parameter 'wins server'\n"));
}
- }
+ }
if (zero_ip(send_ip)) return NULL;
return queue_netbios_packet(wins_subnet,fd, quest_type, state,
name, name_type, nb_flags, ttl,
server_type,my_name,my_comment,
- bcast, recurse, send_ip, reply_to_ip);
+ False, True, send_ip, reply_to_ip);
}
diff --git a/source/nameserv.c b/source/nameserv.c
index 96bb1c0eac8..ccd0ef379cb 100644
--- a/source/nameserv.c
+++ b/source/nameserv.c
@@ -103,7 +103,7 @@ void remove_name_entry(struct subnet_record *d, char *name,int type)
/* not a WINS server: we have to release them on the network */
queue_netbios_pkt_wins(ClientNMB,NMB_REL,NAME_RELEASE,
name, type, 0, 0,0,NULL,NULL,
- False, True, ipzero, ipzero);
+ ipzero, ipzero);
}
}
else
@@ -163,7 +163,7 @@ void add_my_name_entry(struct subnet_record *d,char *name,int type,int nb_flags)
queue_netbios_pkt_wins(ClientNMB,
re_reg ? NMB_REG_REFRESH : NMB_REG, NAME_REGISTER,
name, type, nb_flags, GET_TTL(0),0,NULL,NULL,
- False, True, ipzero, ipzero);
+ ipzero, ipzero);
}
}
else
@@ -308,7 +308,7 @@ for domain master on workgroup %s\n", myworkgroup));
NAME_QUERY_DOMAIN,
myworkgroup, 0x1b,
0, 0,0,NULL,NULL,
- False, True, ipzero, ipzero);
+ ipzero, ipzero);
}
}
}
diff --git a/source/nameservreply.c b/source/nameservreply.c
index e5976bb7429..5b9c476549d 100644
--- a/source/nameservreply.c
+++ b/source/nameservreply.c
@@ -42,7 +42,8 @@ extern struct in_addr wins_ip;
send a registration / release response: pos/neg
**************************************************************************/
static void send_name_response(int fd, struct in_addr from_ip,
- int name_trn_id, int opcode, BOOL success, BOOL recurse,
+ int name_trn_id, int opcode, BOOL success,
+ BOOL recursion_available, BOOL recursion_desired,
struct nmb_name *reply_name, int nb_flags, int ttl,
struct in_addr ip)
{
@@ -56,7 +57,7 @@ static void send_name_response(int fd, struct in_addr from_ip,
/* NEGATIVE RESPONSE */
rcode = 6;
}
- else if (opcode == NMB_REG && recurse == False)
+ else if (opcode == NMB_REG && !recursion_available)
{
/* END-NODE CHALLENGE REGISTRATION RESPONSE */
rcode = 0;
@@ -73,7 +74,8 @@ static void send_name_response(int fd, struct in_addr from_ip,
p.packet_type = NMB_PACKET;
reply_netbios_packet(&p,name_trn_id,
- rcode,opcode,opcode,recurse,
+ rcode,opcode,opcode,
+ recursion_available, recursion_desired,
reply_name, 0x20, 0x1,
ttl,
rdata, 6);
@@ -93,8 +95,10 @@ void add_name_respond(struct subnet_record *d, int fd, struct in_addr from_ip,
nb_flags,ttl,REGISTER,register_ip,False,True);
/* reply yes or no to the host that requested the name */
+ /* see rfc1002.txt - 4.2.10 and 4.2.11 */
send_name_response(fd,from_ip, response_id, NMB_REG,
- new_owner, False,
+ new_owner,
+ True, True,
name, nb_flags, ttl, reply_to_ip);
}
@@ -160,7 +164,7 @@ subnet %s\n", namestr(&nmb->question.question_name), n->name.name_type,
/* Send a NAME RELEASE RESPONSE (pos/neg) see rfc1002.txt 4.2.10-11 */
send_name_response(p->fd,p->ip, nmb->header.name_trn_id, NMB_REL,
- success, nmb->header.nm_flags.recursion_desired,
+ success, False, False,
&nmb->question.question_name, nb_flags, 0, ip);
}
@@ -301,26 +305,29 @@ void reply_name_reg(struct packet_struct *p)
/* send WAIT ACKNOWLEDGEMENT see rfc1002.txt 4.2.16 */
reply_netbios_packet(p,nmb->header.name_trn_id,
- 0,NMB_WAIT_ACK,NMB_WAIT_ACK,False,
+ 0,NMB_WAIT_ACK,NMB_WAIT_ACK,
+ False,False,
reply_name, 0x0a, 0x01,
15*1000, /* 15 seconds long enough to wait? */
rdata, 2);
/* initiate some enquiries to the current owner. */
queue_netbios_packet(d,ClientNMB,NMB_QUERY,
- NAME_REGISTER_CHALLENGE,
- reply_name->name,reply_name->name_type,
- nb_flags,0,0,NULL,NULL,
- False, False, n->ip_flgs[0].ip, p->ip);
+ NAME_REGISTER_CHALLENGE,
+ reply_name->name,reply_name->name_type,
+ nb_flags,0,0,NULL,NULL,
+ False, False,
+ n->ip_flgs[0].ip, p->ip);
}
else
{
- /* Send a NAME REGISTRATION RESPONSE (pos/neg) see rfc1002.txt 4.2.13-14
+ /* Send a NAME REGISTRATION RESPONSE (pos/neg) see rfc1002.txt 4.2.5-6
or an END-NODE CHALLENGE REGISTRATION RESPONSE see rfc1002.txt 4.2.7
*/
send_name_response(p->fd,p->ip, nmb->header.name_trn_id, NMB_REG,
- success, nmb->header.nm_flags.recursion_desired,
+ success,
+ True, True,
reply_name, nb_flags, ttl, ip);
}
}
@@ -471,7 +478,7 @@ void reply_name_status(struct packet_struct *p)
/* Send a POSITIVE NAME STATUS RESPONSE */
reply_netbios_packet(p,nmb->header.name_trn_id,
- 0,NMB_STATUS,0,True,
+ 0,NMB_STATUS,0,False, False,
&nmb->question.question_name,
0x21, 0x01,
0, rdata,PTR_DIFF(buf,rdata));
@@ -507,7 +514,10 @@ void reply_name_query(struct packet_struct *p)
struct nmb_packet *nmb = &p->packet.nmb;
struct nmb_name *question = &nmb->question.question_name;
int name_type = question->name_type;
+
BOOL bcast = nmb->header.nm_flags.bcast;
+ BOOL query_is_to_wins_server = (!bcast &&
+ nmb->header.nm_flags.recursion_desired);
int ttl=0;
int rcode = 0;
int nb_flags = 0;
@@ -516,26 +526,31 @@ void reply_name_query(struct packet_struct *p)
struct subnet_record *d = NULL;
BOOL success = True;
struct name_record *n = NULL;
+ BOOL acting_as_wins_server = lp_wins_support();
/* directed queries are for WINS server: broadcasts are local SELF queries.
the exception is Domain Master names. */
- int search = bcast ? FIND_LOCAL | FIND_WINS: FIND_WINS;
-
- if (search & FIND_LOCAL)
+ if (query_is_to_wins_server)
{
- if (!(d = find_req_subnet(p->ip, bcast)))
+ /* queries to the WINS server involve the WINS server subnet */
+ if (!(d = wins_subnet))
{
- DEBUG(3,("name query: bcast %s not known\n",
+ DEBUG(3,("name query: wins search %s not known\n",
inet_ntoa(p->ip)));
success = False;
}
}
else
{
- if (!(d = wins_subnet))
+ /* queries to the WINS client involve, unfortunately, the WINS subnet
+ because it contains WINS client (SELF) entries, as _well_ as WINS
+ server entries. not good.
+ */
+
+ if (!(d = find_subnet(*iface_bcast(p->ip))))
{
- DEBUG(3,("name query: wins search %s not known\n",
+ DEBUG(3,("name query: interface for %s not known\n",
inet_ntoa(p->ip)));
success = False;
}
@@ -544,12 +559,6 @@ void reply_name_query(struct packet_struct *p)
DEBUG(3,("Name query from %s for name %s<0x%x>\n",
inet_ntoa(p->ip), question->name, question->name_type));
- if (search == 0)
- {
- /* eh? no criterion for searching database. help! */
- success = False;
- }
-
if (!bcast && (name_type == 0x1d) && lp_wins_support())
{
/* see WINS manager HELP - 'How WINS Handles Special Names' */
@@ -560,7 +569,7 @@ void reply_name_query(struct packet_struct *p)
if (success)
{
/* look up the name in the cache */
- n = find_name_search(&d, question, search, p->ip);
+ n = find_name_search(&d, question, FIND_LOCAL, p->ip);
/* it is a name that already failed DNS lookup or it's expired */
if (n && (n->source == DNSFAIL ||
@@ -644,10 +653,15 @@ void reply_name_query(struct packet_struct *p)
putip(&rdata[2],(char *)&retip);
}
+ /* see rfc1002.txt 4.2.13 */
+
reply_netbios_packet(p,nmb->header.name_trn_id,
- rcode,NMB_QUERY,0,True,
- &nmb->question.question_name,
- 0x20, 0x01,
- ttl,
- rdata, success ? 6 : 0);
+ rcode,NMB_QUERY,0,
+ (query_is_to_wins_server && acting_as_wins_server ?
+ True : False), /* recursion_available flag */
+ True, /* recursion_desired_flag */
+ &nmb->question.question_name,
+ 0x20, 0x01,
+ ttl,
+ rdata, success ? 6 : 0);
}
diff --git a/source/nmbsync.c b/source/nmbsync.c
index fd85c82e2cd..f2161f631af 100644
--- a/source/nmbsync.c
+++ b/source/nmbsync.c
@@ -20,6 +20,8 @@
*/
+/* We *must have REPLACE_GETPASS defined here before the includes. */
+#define REPLACE_GETPASS
#include "includes.h"
extern int ClientNMB;
diff --git a/source/param/loadparm.c b/source/param/loadparm.c
index 8c048ad0798..ad9bf83886d 100644
--- a/source/param/loadparm.c
+++ b/source/param/loadparm.c
@@ -1395,11 +1395,26 @@ check if a config file has changed date
BOOL lp_file_list_changed(void)
{
struct file_lists *f = file_lists;
- while (f) {
+ DEBUG(6,("lp_file_list_changed()\n"));
+
+ while (f)
+ {
pstring n2;
+ time_t mod_time;
+
strcpy(n2,f->name);
standard_sub_basic(n2);
- if (f->modtime != file_modtime(n2)) return(True);
+
+ DEBUG(6,("file %s -> %s last mod_time: %s\n",
+ f->name, n2, ctime(&f->modtime)));
+
+ mod_time = file_modtime(n2);
+
+ if (f->modtime != mod_time)
+ {
+ DEBUG(6,("file %s modified: %s\n", n2, ctime(&mod_time)));
+ return(True);
+ }
f = f->next;
}
return(False);
diff --git a/source/printing/printing.c b/source/printing/printing.c
index c4dd9803ebe..c83d2169891 100644
--- a/source/printing/printing.c
+++ b/source/printing/printing.c
@@ -929,8 +929,8 @@ int get_printqueue(int snum,int cnum,print_queue_struct **queue,
if (!printername || !*printername)
{
- DEBUG(6,("replacing printer name with service (snum=(%s,%d))\n",
- lp_servicename(snum),snum));
+ DEBUG(6,("xx replacing printer name with service (snum=(%s,%d))\n",
+ lp_servicename(snum),snum));
printername = lp_servicename(snum);
}
@@ -1080,3 +1080,23 @@ void status_printjob(int cnum,int snum,int jobid,int status)
}
+
+/****************************************************************************
+we encode print job numbers over the wire so that when we get them back we can
+tell not only what print job they are but also what service it belongs to,
+this is to overcome the problem that windows clients tend to send the wrong
+service number when doing print queue manipulation!
+****************************************************************************/
+int printjob_encode(int snum, int job)
+{
+ return ((snum&0xFF)<<8) | (job & 0xFF);
+}
+
+/****************************************************************************
+and now decode them again ...
+****************************************************************************/
+void printjob_decode(int jobid, int *snum, int *job)
+{
+ (*snum) = (jobid >> 8) & 0xFF;
+ (*job) = jobid & 0xFF;
+}
diff --git a/source/script/mkproto.awk b/source/script/mkproto.awk
index 08b13d46108..f2b76f20c97 100644
--- a/source/script/mkproto.awk
+++ b/source/script/mkproto.awk
@@ -64,7 +64,7 @@ BEGIN {
next;
}
-!/^unsigned|^mode_t|^DIR|^user|^int|^char|^uint|^struct|^BOOL|^void|^time|^shm_offset_t/ {
+!/^unsigned|^mode_t|^DIR|^user|^int|^char|^uint|^struct|^BOOL|^void|^time|^smb_shm_offset_t|^shm_offset_t|^enum remote_arch_types/ {
next;
}
diff --git a/source/smbd/ipc.c b/source/smbd/ipc.c
index e21021c0ac5..55e293d7ffd 100644
--- a/source/smbd/ipc.c
+++ b/source/smbd/ipc.c
@@ -480,7 +480,7 @@ static void fill_printjob_info(int cnum, int snum, int uLevel,
/* the client expects localtime */
t -= TimeDiff(t);
- PACKI(desc,"W",((snum%0xFF)<<8) | (queue->job%0xFF)); /* uJobId */
+ PACKI(desc,"W",printjob_encode(snum, queue->job)); /* uJobId */
if (uLevel == 1) {
PACKS(desc,"B21",queue->user); /* szUserName */
PACKS(desc,"B",""); /* pad */
@@ -1405,11 +1405,10 @@ static BOOL api_RDosPrintJobDel(int cnum,uint16 vuid, char *param,char *data,
char *str1 = param+2;
char *str2 = skip_string(str1,1);
char *p = skip_string(str2,1);
- int jobid = (SVAL(p,0)&0xFF); /* the snum and jobid are encoded
- by the print queue api */
- int snum = (SVAL(p,0)>>8);
+ int jobid, snum;
int i, count;
+ printjob_decode(SVAL(p,0), &snum, &jobid);
/* check it's a supported varient */
if (!(strcsequal(str1,"W") && strcsequal(str2,"")))
@@ -1429,7 +1428,7 @@ static BOOL api_RDosPrintJobDel(int cnum,uint16 vuid, char *param,char *data,
count = get_printqueue(snum,cnum,&queue,NULL);
for (i=0;i>8);
+ int jobid, snum;
int uLevel = SVAL(p,2);
int function = SVAL(p,4); /* what is this ?? */
int i;
char *s = data;
+
+ printjob_decode(SVAL(p,0), &snum, &jobid);
*rparam_len = 4;
*rparam = REALLOC(*rparam,*rparam_len);
@@ -1565,7 +1564,7 @@ static BOOL api_PrintJobInfo(int cnum,uint16 vuid,char *param,char *data,
lpq_reset(snum);
count = get_printqueue(snum,cnum,&queue,NULL);
for (i=0;i> 8; /*## valid serice number??*/
- job = uJobId & 0xFF;
+ printjob_decode(SVAL(p,0), &snum, &job);
if (snum < 0 || !VALID_SNUM(snum)) return(False);
count = get_printqueue(snum,cnum,&queue,&status);
for (i = 0; i < count; i++) {
- if ((queue[i].job % 0xFF) == job) break;
+ if ((queue[i].job & 0xFF) == job) break;
}
if (mdrcnt > 0) *rdata = REALLOC(*rdata,mdrcnt);
desc.base = *rdata;
diff --git a/source/smbd/mangle.c b/source/smbd/mangle.c
index 96e787b07fb..a08402a85ea 100644
--- a/source/smbd/mangle.c
+++ b/source/smbd/mangle.c
@@ -414,9 +414,9 @@ static void do_fwd_mangled_map(char *s, char *MangledMap)
while (*start) {
while ((*start) && (*start != '('))
start++;
- start++; /* Skip the ( */
if (!*start)
continue; /* Always check for the end. */
+ start++; /* Skip the ( */
end = start; /* Search for the ' ' or a ')' */
DEBUG(5,("Start of first in pair '%s'\n", start));
while ((*end) && !((*end == ' ') || (*end == ')')))
diff --git a/source/smbd/password.c b/source/smbd/password.c
index 2740304cc4f..ed79d658a66 100644
--- a/source/smbd/password.c
+++ b/source/smbd/password.c
@@ -1576,11 +1576,25 @@ BOOL server_cryptkey(char *buf)
p = outbuf+len;
name_mangle(desthost,p,' ');
len += name_len(p);
+ p = outbuf+len;
/* and my name */
- p = outbuf+len;
- name_mangle(remote_machine,p,' ');
- len += name_len(p);
+ /* Fix from Frank Varnavas .
+ We cannot use the same name as the client to
+ the NT password server, as NT will drop client
+ connections if the same client name connects
+ twice. Instead, synthesize a name from our pid.
+ and the remote machine name.
+ */
+ {
+ char buf[32]; /* create name as PIDname */
+ sprintf(buf,"%d", getpid());
+ strncpy(&buf[strlen(buf)], remote_machine, 31 - strlen(buf));
+ buf[31] = '\0';
+ DEBUG(1,("negprot w/password server as %s\n",buf));
+ name_mangle(buf,p,' ');
+ len += name_len(p);
+ }
_smb_setlen(outbuf,len);
CVAL(outbuf,0) = 0x81;
diff --git a/source/smbd/reply.c b/source/smbd/reply.c
index cadd63e0457..773063131af 100644
--- a/source/smbd/reply.c
+++ b/source/smbd/reply.c
@@ -261,7 +261,26 @@ int reply_tcon_and_X(char *inbuf,char *outbuf,int length,int bufsize)
if (connection_num < 0)
return(connection_error(inbuf,outbuf,connection_num));
- set_message(outbuf,2,strlen(devicename)+1,True);
+ if (Protocol < PROTOCOL_NT1)
+ {
+ set_message(outbuf,2,strlen(devicename)+1,True);
+ strcpy(smb_buf(outbuf),devicename);
+ }
+ else
+ {
+ char *fsname = "NTFS";
+ char *p;
+
+ set_message(outbuf,3,3,True);
+
+ p = smb_buf(outbuf);
+ strcpy(p,devicename); p = skip_string(p,1); /* device name */
+ strcpy(p,fsname); p = skip_string(p,1); /* filesystem type e.g NTFS */
+
+ set_message(outbuf,3,PTR_DIFF(p,smb_buf(outbuf)),False);
+
+ SSVAL(outbuf, smb_vwv2, 0x0); /* optional support */
+ }
DEBUG(3,("%s tconX service=%s user=%s cnum=%d\n",timestring(),service,user,connection_num));
@@ -269,8 +288,6 @@ int reply_tcon_and_X(char *inbuf,char *outbuf,int length,int bufsize)
SSVAL(inbuf,smb_tid,connection_num);
SSVAL(outbuf,smb_tid,connection_num);
- strcpy(smb_buf(outbuf),devicename);
-
return chain_reply(inbuf,outbuf,length,bufsize);
}
@@ -350,8 +367,24 @@ int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize)
} else {
uint16 passlen1 = SVAL(inbuf,smb_vwv7);
uint16 passlen2 = SVAL(inbuf,smb_vwv8);
+ uint32 client_caps = IVAL(inbuf,smb_vwv11);
+ enum remote_arch_types ra_type = get_remote_arch();
+
char *p = smb_buf(inbuf);
+ /* client_caps is used as final determination if client is NT or Win95.
+ This is needed to return the correct error codes in some
+ circumstances.
+ */
+
+ if(ra_type == RA_WINNT || ra_type == RA_WIN95)
+ {
+ if(client_caps & (CAP_NT_SMBS | CAP_STATUS32))
+ set_remote_arch( RA_WINNT);
+ else
+ set_remote_arch( RA_WIN95);
+ }
+
if (passlen1 != 24 && passlen2 != 24)
doencrypt = False;
@@ -2463,7 +2496,7 @@ int reply_printqueue(char *inbuf,char *outbuf)
{
put_dos_date2(p,0,queue[i].time);
CVAL(p,4) = (queue[i].status==LPQ_PRINTING?2:3);
- SSVAL(p,5,queue[i].job);
+ SSVAL(p,5,printjob_encode(SNUM(cnum), queue[i].job));
SIVAL(p,7,queue[i].size);
CVAL(p,11) = 0;
StrnCpy(p+12,queue[i].user,16);
diff --git a/source/smbd/server.c b/source/smbd/server.c
index aaf62fdcad9..24dc8fb51f4 100644
--- a/source/smbd/server.c
+++ b/source/smbd/server.c
@@ -397,7 +397,7 @@ static BOOL scan_directory(char *path, char *name,int cnum,BOOL docache)
if (!name_map_mangle(name2,False,SNUM(cnum))) continue;
if ((mangled && mangled_equal(name,name2))
- || fname_equal(name, dname))
+ || fname_equal(name, name2)) /* name2 here was changed to dname - since 1.9.16p2 - not sure of reason (jra) */
{
/* we've found the file, change it's name and return */
if (docache) DirCacheAdd(path,name,dname,SNUM(cnum));
@@ -1532,7 +1532,12 @@ void open_file_shared(int fnum,int cnum,char *fname,int share_mode,int ofun,
if (strstr(fname,".+,;=[]."))
{
unix_ERR_class = ERRDOS;
+ /* OS/2 Workplace shell fix - may be main code stream in a later release. */
+#ifdef OS2_WPS_FIX
+ unix_ERR_code = ERRcannotopen;
+#else /* OS2_WPS_FIX */
unix_ERR_code = ERROR_EAS_NOT_SUPPORTED;
+#endif /* OS2_WPS_FIX */
return;
}
@@ -1978,6 +1983,19 @@ struct
{0,0,0}
};
+/* Mapping for old clients. */
+
+struct
+{
+ int new_smb_error;
+ int old_smb_error;
+ int protocol_level;
+ enum remote_arch_types valid_ra_type;
+} old_client_errmap[] =
+{
+ {ERRbaddirectory, ERRbadpath, (int)PROTOCOL_NT1, RA_WINNT},
+ {0,0,0}
+};
/****************************************************************************
create an error packet from errno
@@ -1998,17 +2016,40 @@ int unix_error_packet(char *inbuf,char *outbuf,int def_class,uint32 def_code,int
else
{
while (unix_smb_errmap[i].smbclass != 0)
- {
- if (unix_smb_errmap[i].unixerror == errno)
+ {
+ if (unix_smb_errmap[i].unixerror == errno)
{
eclass = unix_smb_errmap[i].smbclass;
ecode = unix_smb_errmap[i].smbcode;
break;
}
i++;
- }
+ }
}
+ /* Make sure we don't return error codes that old
+ clients don't understand. */
+
+ /* JRA - unfortunately, WinNT needs some error codes
+ for apps to work correctly, Win95 will break if
+ these error codes are returned. But they both
+ negotiate the *same* protocol. So we need to use
+ the revolting 'remote_arch' enum to tie break.
+
+ There must be a better way of doing this...
+ */
+
+ for(i = 0; old_client_errmap[i].new_smb_error != 0; i++)
+ {
+ if(((Protocol < old_client_errmap[i].protocol_level) ||
+ (old_client_errmap[i].valid_ra_type != get_remote_arch())) &&
+ (old_client_errmap[i].new_smb_error == ecode))
+ {
+ ecode = old_client_errmap[i].old_smb_error;
+ break;
+ }
+ }
+
return(error_packet(inbuf,outbuf,eclass,ecode,line));
}
@@ -3025,7 +3066,6 @@ struct {
****************************************************************************/
static int reply_negprot(char *inbuf,char *outbuf)
{
- extern fstring remote_arch;
int outsize = set_message(outbuf,1,0,True);
int Index=0;
int choice= -1;
@@ -3065,22 +3105,22 @@ static int reply_negprot(char *inbuf,char *outbuf)
switch ( arch ) {
case ARCH_SAMBA:
- strcpy(remote_arch,"Samba");
+ set_remote_arch(RA_SAMBA);
break;
case ARCH_WFWG:
- strcpy(remote_arch,"WfWg");
+ set_remote_arch(RA_WFWG);
break;
case ARCH_WIN95:
- strcpy(remote_arch,"Win95");
+ set_remote_arch(RA_WIN95);
break;
case ARCH_WINNT:
- strcpy(remote_arch,"WinNT");
+ set_remote_arch(RA_WINNT);
break;
case ARCH_OS2:
- strcpy(remote_arch,"OS2");
+ set_remote_arch(RA_OS2);
break;
default:
- strcpy(remote_arch,"UNKNOWN");
+ set_remote_arch(RA_UNKNOWN);
break;
}
@@ -3471,12 +3511,12 @@ void exit_server(char *reason)
/****************************************************************************
do some standard substitutions in a string
****************************************************************************/
-void standard_sub(int cnum,char *string)
+void standard_sub(int cnum,char *str)
{
if (VALID_CNUM(cnum)) {
char *p, *s, *home;
- for ( s=string ; (p=strchr(s, '%')) != NULL ; s=p ) {
+ for ( s=str ; (p=strchr(s, '%')) != NULL ; s=p ) {
switch (*(p+1)) {
case 'H' : if ((home = get_home_dir(Connections[cnum].user))!=NULL)
string_sub(p,"%H",home);
@@ -3492,7 +3532,7 @@ void standard_sub(int cnum,char *string)
}
}
}
- standard_sub_basic(string);
+ standard_sub_basic(str);
}
/*
diff --git a/source/smbd/trans2.c b/source/smbd/trans2.c
index 80529240590..19c1158658c 100644
--- a/source/smbd/trans2.c
+++ b/source/smbd/trans2.c
@@ -341,7 +341,7 @@ static int get_lanman2_dir_entry(int cnum,char *path_mask,int dirtype,int info_l
strcpy(pathreal,Connections[cnum].dirpath);
if(needslash)
strcat(pathreal,"/");
- strcat(pathreal,fname);
+ strcat(pathreal,dname);
if (sys_stat(pathreal,&sbuf) != 0)
{
DEBUG(5,("get_lanman2_dir_entry:Couldn't stat [%s] (%s)\n",pathreal,strerror(errno)));
@@ -368,13 +368,11 @@ static int get_lanman2_dir_entry(int cnum,char *path_mask,int dirtype,int info_l
}
}
-
+ name_map_mangle(fname,False,SNUM(cnum));
p = pdata;
nameptr = p;
- name_map_mangle(fname,False,SNUM(cnum));
-
nt_extmode = mode ? mode : NT_FILE_ATTRIBUTE_NORMAL;
switch (info_level)
@@ -1301,11 +1299,7 @@ static int call_trans2setfilepathinfo(char *inbuf, char *outbuf, int length,
if (total_data > 0 && IVAL(pdata,0) == total_data) {
/* uggh, EAs for OS2 */
DEBUG(4,("Rejecting EA request with total_data=%d\n",total_data));
-#ifdef OS2_WPS_FIX /* This may become the main code stream in a later release */
- return(ERROR(ERRDOS,ERRcannotopen));
-#else /* OS2_WPS_FIX */
return(ERROR(ERRDOS,ERROR_EAS_NOT_SUPPORTED));
-#endif /* OS2_WPS_FIX */
}
switch (info_level)
--
cgit
From 63c4dc3c69a0ca49e94af94cc9375ba08d2f8b53 Mon Sep 17 00:00:00 2001
From: Jeremy Allison
Date: Fri, 5 Sep 1997 20:40:34 +0000
Subject: Bringing 1.9.17 patch tree up to date for documentation. Preparing to
release 1.9.17p1. Jeremy (jallison@whistle.com)
---
WHATSNEW.txt | 41 +++++++++++++++++++++++++++++----
docs/MIRRORS | 33 ---------------------------
docs/announce | 2 +-
docs/faq/sambafaq-3.html | 2 +-
docs/faq/sambafaq.sgml | 2 +-
docs/faq/sambafaq.txt | 2 +-
docs/history | 2 +-
docs/manpages/smb.conf.5 | 11 ++++++---
docs/samba.faq | 2 +-
docs/textdocs/BROWSING.txt | 4 ++--
docs/textdocs/DIAGNOSIS.txt | 11 ++++++++-
docs/textdocs/DOMAIN.txt | 42 ++++++++++++++++------------------
docs/textdocs/DOMAIN_CONTROL.txt | 2 +-
docs/textdocs/GOTCHAS.txt | 4 ++--
docs/textdocs/Passwords.txt | 2 +-
docs/textdocs/Support.txt | 49 ++++++++++++++++++++++++++++++++++++++--
docs/textdocs/UNIX-SMB.txt | 4 ++--
docs/textdocs/UNIX_INSTALL.txt | 2 +-
18 files changed, 136 insertions(+), 81 deletions(-)
delete mode 100644 docs/MIRRORS
diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index 6719d439e4f..500a4726bf2 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -1,8 +1,41 @@
- WHATS NEW IN 1.9.17 - August 25th 1997
- ======================================
+ WHATS NEW IN 1.9.17p1 - September 5 1997
+ ========================================
-New stable release of Samba.
-----------------------------
+New stable patch release: Samba - version 1.9.17p1.
+---------------------------------------------------
+
+This is a patch release which superceedes the
+last stable release of Samba, release 1.9.17.
+This release fixes the few bugs that users reported
+in the previous stable release (1.9.17).
+
+These bugfixes are :
+
+Fix for DOS and Windows 95 clients having trouble
+delting files on a Samba share in a DOS command line
+environment.
+
+Fixes to set the 'flag' bits correctly when talking to a
+non-Samba WINS server.
+
+Fix for NT clients being dropped when using security=server.
+
+Fixes to the printer queue reporting code.
+
+Fix for the name map mangle bug (mangling .html -> .htm was
+not working).
+
+If you are not affected by any of these problems then there
+is no need to upgrade.
+
+The release notes from the previous stable release follow.
+
+The Samba Team.
+
+-------------Previous release notes-------------------------
+
+New stable release of Samba - 1.9.17
+------------------------------------
This is the new stable release of Samba, superceeding
the last stable release 1.9.16p11. All users are
diff --git a/docs/MIRRORS b/docs/MIRRORS
deleted file mode 100644
index a055860e999..00000000000
--- a/docs/MIRRORS
+++ /dev/null
@@ -1,33 +0,0 @@
-The main Samba ftp site is samba.anu.edu.au in pub/samba/. Contact
-samba-bugs@samba.anu.edu.au for help with this site.
-
-Mirror sites include:
-
-ftp://nimbus.anu.edu.au/pub/tridge/samba
-ftp://sunsite.auc.dk/pub/unix/networking/samba/
-ftp://src.doc.ic.ac.uk/packages/samba/
-ftp://choc.satech.net.au/pub/samba/
-ftp://ftp.uni-trier.de/pub/unix/network/samba/
-ftp://sunsite.mff.cuni.cz/Net/Protocols/Samba/
-ftp://ring.aist.go.jp/archives/net/samba/
-ftp://ring.asahi-net.or.jp/archives/net/samba/
-ftp://ftp.cs.ucr.edu/pub/software/samba
-ftp://ftp.ua.pt/pub/misc/samba/
-ftp://sunsite.unc.edu/pub/Linux/system/Network/samba/
-
-There are several others. Give archie a try.
-
-SCO binaries available from:
-ftp://ftp.markv.com/pub/samba (built by lance@fox.com)
-
-AIX and DEC OSF/1 binaries are available from:
-ftp://151.99.220.5/pub/samba (built by davide.migliavacca@inferentia.inet.it)
-
-QNX binaries and source code:
-ftp://quics.qnx.com/usr/free/staging/samba
-
-Http sites include:
-
-http://samba.canberra.edu.au/pub/samba
-http://www.choc.satech.net.au/pub/samba/
-
diff --git a/docs/announce b/docs/announce
index 18e34b68c2b..adcde8966f8 100644
--- a/docs/announce
+++ b/docs/announce
@@ -28,7 +28,7 @@ allows you to access a SMB printer (such as one attached to an OS/2 or
WfWg server) from Unix, using an entry in /etc/printcap, or by
explicitly specifying the command used to print files.
-What are it's features?
+What are its features?
------------------------
Samba supports many features that are not supported in other SMB
diff --git a/docs/faq/sambafaq-3.html b/docs/faq/sambafaq-3.html
index 39cded21ec1..8b24de54f23 100644
--- a/docs/faq/sambafaq-3.html
+++ b/docs/faq/sambafaq-3.html
@@ -85,7 +85,7 @@ To syncronize your PC's clock with your Samba server:
Each time you start your computer (or login for Win95) your PC will
-synchronize it's clock with your Samba server.
+synchronize its clock with your Samba server.
Alternativley, if you clients support Domain Logons, you can setup Domain Logons with Samba
- see:
BROWSING.txt *** for more information.
diff --git a/docs/faq/sambafaq.sgml b/docs/faq/sambafaq.sgml
index 7a618d47c8f..951ad822edb 100644
--- a/docs/faq/sambafaq.sgml
+++ b/docs/faq/sambafaq.sgml
@@ -570,7 +570,7 @@ To syncronize your PC's clock with your Samba server:
- Close the properties dialog box by choosing 'OK'
Each time you start your computer (or login for Win95) your PC will
-synchronize it's clock with your Samba server.
+synchronize its clock with your Samba server.
Alternativley, if you clients support Domain Logons, you can setup Domain Logons with Samba
- see: *** for more information.
diff --git a/docs/faq/sambafaq.txt b/docs/faq/sambafaq.txt
index 2bc45fb7945..e7f5f32a20d 100644
--- a/docs/faq/sambafaq.txt
+++ b/docs/faq/sambafaq.txt
@@ -841,7 +841,7 @@
o Close the properties dialog box by choosing 'OK'
Each time you start your computer (or login for Win95) your PC will
- synchronize it's clock with your Samba server.
+ synchronize its clock with your Samba server.
Alternativley, if you clients support Domain Logons, you can setup
Domain Logons with Samba - see: BROWSING.txt
diff --git a/docs/history b/docs/history
index a86160e854d..dd9e83719ff 100644
--- a/docs/history
+++ b/docs/history
@@ -112,7 +112,7 @@ code! I wrote back saying it was OK, but never heard from him again. I
don't know if it went on the cd-rom.
Anyway, the next big event was in December 1993, when Dan again sent
-me an e-mail saying my server had "raised it's ugly head" on
+me an e-mail saying my server had "raised its ugly head" on
comp.protocols.tcpip.ibmpc. I had a quick look on the group, and was
surprised to see that there were people interested in this thing.
diff --git a/docs/manpages/smb.conf.5 b/docs/manpages/smb.conf.5
index 1eed1fcd868..a0a96f26ff6 100644
--- a/docs/manpages/smb.conf.5
+++ b/docs/manpages/smb.conf.5
@@ -1585,7 +1585,7 @@ see "debug level"
.SS logon path (G)
This parameter specifies the home directory where roaming profiles
-(USER.DAT / USER.MAN files) are stored.
+(USER.DAT / USER.MAN files for Windows 95) are stored.
This option takes the standard substitutions, allowing you to have
separate logon scripts for each user or machine. It also specifies
@@ -1603,11 +1603,16 @@ be made read-only. It is not adviseable that the USER.DAT file be made
read-only - rename it to USER.MAN to achieve the desired effect
(a MANdatory profile).
+Windows clients can sometimes maintain a connection to the [homes]
+share, even though there is no user logged in. Therefore, it is
+vital that the logon path does not include a reference to the
+homes share (i.e \\\\%L\\HOMES\profile_path will cause problems).
+
.B Default:
- logon path = \\\\%L\\%U
+ logon path = \\\\%L\\%U\\profile
.B Example:
- logon path = \\\\PROFILESERVER\\HOME_DIR\\%U
+ logon path = \\\\PROFILESERVER\\HOME_DIR\\%U\\PROFILE
.SS logon script (G)
diff --git a/docs/samba.faq b/docs/samba.faq
index e74585b9769..19126439500 100644
--- a/docs/samba.faq
+++ b/docs/samba.faq
@@ -605,7 +605,7 @@ To syncronize your PC's clock with your Samba server:
* Close the properties dialog box by choosing 'OK'
Each time you start your computer (or login for Win95) your PC will
-synchronize it's clock with your Samba server.
+synchronize its clock with your Samba server.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/docs/textdocs/BROWSING.txt b/docs/textdocs/BROWSING.txt
index 12d3417a294..d8362f15299 100644
--- a/docs/textdocs/BROWSING.txt
+++ b/docs/textdocs/BROWSING.txt
@@ -320,7 +320,7 @@ all smb.conf files :
wins server =
where is either the DNS name of the WINS server
-machine or it's IP address.
+machine or its IP address.
Note that this line MUST NOT BE SET in the smb.conf file of the Samba
server acting as the WINS server itself. If you set both the
@@ -358,7 +358,7 @@ server as a domain master browser set the following option in the
domain master = yes
The domain master browser should also preferrably be the local master
-browser for it's own subnet. In order to achieve this set the following
+browser for its own subnet. In order to achieve this set the following
options in the [global] section of the smb.conf file :
domain master = yes
diff --git a/docs/textdocs/DIAGNOSIS.txt b/docs/textdocs/DIAGNOSIS.txt
index 5f20f610310..11eb91b2ff8 100644
--- a/docs/textdocs/DIAGNOSIS.txt
+++ b/docs/textdocs/DIAGNOSIS.txt
@@ -69,7 +69,12 @@ run ping.
If you get a message saying "host not found" or similar then your DNS
software or /etc/hosts file is not correctly setup. It is possible to
run samba without DNS entries for the server and client, but I assume
-you do have correct entries for the remainder of these tests.
+you do have correct entries for the remainder of these tests.
+
+Another reason why ping might fail is if your host is running firewall
+software. You will need to relax the rules to let in the workstation
+in question, perhaps by allowing access from another subnet (on Linux
+this is done via the ipfwadm program.)
TEST 3:
@@ -208,6 +213,10 @@ same fixes apply as they did for the "smbclient -L" test above. In
particular, make sure your "hosts allow" line is correct (see the man
pages)
+If you get "specified computer is not receiving requests" or similar
+it probably means that the host is not contactable via tcp services.
+Check to see if the host is running tcp wrappers, and if so add an entry in
+the hosts.allow file for your client (or subnet, etc.)
TEST 9:
diff --git a/docs/textdocs/DOMAIN.txt b/docs/textdocs/DOMAIN.txt
index 547e1b6cf8c..3cd8a125b7b 100644
--- a/docs/textdocs/DOMAIN.txt
+++ b/docs/textdocs/DOMAIN.txt
@@ -1,30 +1,21 @@
Contributor: Samba Team
-Updated: August 25, 1997
+Updated: June 27, 1997
Subject: Network Logons and Roving Profiles
===========================================================================
A domain and a workgroup are exactly the same thing in terms of network
-traffic, except for the client logon sequence. Some kind of distributed
-authentication database is associated with a domain (there are quite a few
-choices) and this adds so much flexibility that many people think of a
-domain as a completely different entity to a workgroup. From Samba's
-point of view a client connecting to a service presents an authentication
-token, and it if it is valid they have access. Samba does not care what
-mechanism was used to generate that token in the first place.
+browsing. The difference is that a distributable authentication
+database is associated with a domain, for secure login access to a
+network. Also, different access rights can be granted to users if they
+successfully authenticate against a domain logon server (samba does not
+support this, but NT server and other systems based on NT server do).
The SMB client logging on to a domain has an expectation that every other
server in the domain should accept the same authentication information.
However the network browsing functionality of domains and workgroups is
identical and is explained in BROWSING.txt.
-There are some implementation differences: Windows 95 can be a member of
-both a workgroup and a domain, but Windows NT cannot. Windows 95 also
-has the concept of an "alternative workgroup". Samba can only be a
-member of a single workgroup or domain, although this is due to change
-with a future version when nmbd will be split into two daemons, one
-for WINS and the other for browsing (NetBIOS.txt explains what WINS is.)
-
Issues related to the single-logon network model are discussed in this
document. Samba supports domain logons, network logon scripts, and user
profiles. The support is still experimental, but it seems to work.
@@ -32,10 +23,8 @@ profiles. The support is still experimental, but it seems to work.
The support is also not complete. Samba does not yet support the sharing
of the Windows NT-style SAM database with other systems. However this is
only one way of having a shared user database: exactly the same effect can
-be achieved by having all servers in a domain share a distributed NIS,
-Kerberos or other authentication database. These other options may or may
-not involve changes to the client software, that depends on the combination
-of client OS, server OS and authentication protocol.
+be achieved by having all servers in a domain share a distributed NIS or
+Kerberos authentication database.
When an SMB client in a domain wishes to logon it broadcast requests for a
logon server. The first one to reply gets the job, and validates its
@@ -147,8 +136,9 @@ In the [global] section of smb.conf set the following (for example):
logon path = \\profileserver\profileshare\profilepath\%U\moreprofilepath
-The default for this option is \\%L\%U, namely \\sambaserver\username,
-The \\L%\%U services is created automatically by the [homes] service.
+The default for this option is \\%L\%U\profile, namely
+\\sambaserver\username\profile. The \\L%\%U services is created
+automatically by the [homes] service.
If you are using a samba server for the profiles, you _must_ make the
share specified in the logon path browseable. Windows 95 appears to
@@ -158,6 +148,10 @@ away. It also attempts to create the components of the full path for
you. If the creation of any component fails, or if it cannot see any
component of the path, the profile creation / reading fails.
+[lkcl 26aug96 - we have discovered a problem where Windows clients can
+maintain a connection to the [homes] share in between logins. The
+[homes] share must NOT therefore be used in a profile path.]
+
Windows 95
----------
@@ -281,8 +275,10 @@ to specify the location of the profile. Samba cannot be a domain
logon server for NT, therefore you will need to manually configure
each and every account. [lkcl 10aug97 - i tried setting the path
in each account to \\samba-server\homes\profile, and discovered that
-this fails for some reason. you have to have \\samba-server\user\profile,
-where user is the username created from the [homes] share].
+this fails because a background process maintains the connection to
+the [homes] share which does _not_ close down in between user logins.
+you have to have \\samba-server\user\profile, where user is the
+username created from the [homes] share].
The entry for the NT 4.0 profile is a _directory_ not a file. The NT
help on profiles mentions that a directory is also created with a .PDS
diff --git a/docs/textdocs/DOMAIN_CONTROL.txt b/docs/textdocs/DOMAIN_CONTROL.txt
index bebac3e900c..0b077320cdb 100644
--- a/docs/textdocs/DOMAIN_CONTROL.txt
+++ b/docs/textdocs/DOMAIN_CONTROL.txt
@@ -94,7 +94,7 @@ have at least one Backup Domain Controller (BDC).
The PDC and BDCs then participate in replication of the SAM database so that
each Domain Controlling participant will have an up to date SAM component
-within it's registry.
+within its registry.
Samba can NOT at this time function as a Domain Controller for any of these
security services, but like all other domain members can interact with the
diff --git a/docs/textdocs/GOTCHAS.txt b/docs/textdocs/GOTCHAS.txt
index d4e5f3e842d..bc5c6dae853 100644
--- a/docs/textdocs/GOTCHAS.txt
+++ b/docs/textdocs/GOTCHAS.txt
@@ -48,10 +48,10 @@ Details:
Windows NT checks at start up to see if any domain logon
controllers are already running within the domain. It finds
Samba claiming to offer the service and therefore does NOT
- start it's Network Logon Service.
+ start its Network Logon Service.
Windows NT needs the Windows NT network logon service to gain
- from it's Domain controller's SAM database the security
+ from its Domain controller's SAM database the security
identifier for the user loging on.
Work-around: Stop the Samba nmbd and smbd processes, then on the Windows
diff --git a/docs/textdocs/Passwords.txt b/docs/textdocs/Passwords.txt
index 3d7acac9dd3..f76010c4608 100644
--- a/docs/textdocs/Passwords.txt
+++ b/docs/textdocs/Passwords.txt
@@ -37,7 +37,7 @@ only written and tested for AFS 3.3 and later.
SECURITY = SERVER
=================
-Samba can use a remote server to do it's username/password
+Samba can use a remote server to do its username/password
validation. This allows you to have one central machine (for example a
NT box) control the passwords for the Unix box.
diff --git a/docs/textdocs/Support.txt b/docs/textdocs/Support.txt
index a4fd34aca62..afffc2be505 100644
--- a/docs/textdocs/Support.txt
+++ b/docs/textdocs/Support.txt
@@ -17,6 +17,8 @@ If you want to be added to the list, or want your entry modified then
contact the address below. Please make sure to include a header line
giving the region and country, eg CANBERRA - AUSTRALIA.
+The Samba Team reserves the right not to add support providers.
+
You can contact the maintainers at samba-bugs@samba.anu.edu.au
The support list has now been re-arranged into geographical areas
@@ -27,7 +29,7 @@ Region Number of entries
----------------------------------------------------
AFRICA 2
AMERICA - CENTRAL & SOUTH 3
- AMERICA - USA 31
+ AMERICA - USA 33
ASIA 1
AUSTRALIA & NEW ZEALAND 18
CANADA 8
@@ -299,7 +301,7 @@ Email: jay@wss.net
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-FORT COLLINS, CO - USA
+FORT COLLINS, COLORADO - USA
Granite Computing Solutions
ATTN: Brian Grossman
@@ -314,6 +316,23 @@ WWW solutions. WWW education. Unix education. Custom software
development - eg. http://www.SoftHome.Net/modsim/.
------------------------------------------------------------------------------
+------------------------------------------------------------------------------
+COLORADO - USA
+
+Daylight Software
+1062 Lexington Lane
+Estes Park, CO 80517 USA
+(970) 586-6058
+
+We have experience with Samba under SunOS, Solaris and Linux,
+and also with Windows NT and Microsoft Lan Manager.
+
+Contact: daylight@frii.net
+
+Chris Howard Daylight Software
+daylight@frii.net Estes Park, Colorado USA
+------------------------------------------------------------------------------
+
------------------------------------------------------------------------------
FLORIDA - USA
@@ -384,6 +403,32 @@ Florida area. We are well familiar in the integration of SAMBA and NT
and in SAMBA configuration on AIX, SCO, Linux And SUN Solaris.
------------------------------------------------------------------------------
+------------------------------------------------------------------------------
+FLORIDA - USA
+
+The PC Doctor
+Tampa Bay Interactive
+1314 Tampa Rd STE 120
+Palm Harbor, FL 34683
+
+ph 813.781-2209
+fx 813.571-3805
+
+Contacts: Jared Hall: jhall@tbi.net
+ System Operations: support@tbi.net
+
+Tampa Bay Interactive provides complete Internet solutions for the Small
+Office and Home Office. Specializing in Intel-Based UNIX systems; Linux,
+BSD/OS, FreeBSD, SCO. Proxy Server specialists.
+
+~~ Jared Hall ~~~~~~~ Tampa Bay Interactive
+~~~~~~~~~~~~~~~~~~~~~ 1314 Tampa Rd, #120
+~~ jhall@tbi.net ~~~~ Palm Harbor, FL 34683
+~~ (813) 781-2209 ~~~ (http://www.tbi.net)
+
+Telecom Corner - http://www.tbi.net/~jhall
+------------------------------------------------------------------------------
+
------------------------------------------------------------------------------
GEORGIA - USA
diff --git a/docs/textdocs/UNIX-SMB.txt b/docs/textdocs/UNIX-SMB.txt
index 88a7324dd73..ec2e657c052 100644
--- a/docs/textdocs/UNIX-SMB.txt
+++ b/docs/textdocs/UNIX-SMB.txt
@@ -88,7 +88,7 @@ passwords they are in trouble.
Samba can try to cope with this by either using the "password level"
option which causes Samba to try the offered password with up to the
specified number of case changes, or by using the "password server"
-option which allows Samba to do it's validation via another machine
+option which allows Samba to do its validation via another machine
(typically a WinNT server).
Samba supports the password encryption method used by SMB
@@ -128,7 +128,7 @@ The second major problem is the "opportunistic locking" requested by
some clients. If a client requests opportunistic locking then it is
asking the server to notify it if anyone else tries to do something on
the same file, at which time the client will say if it is willing to
-give up it's lock. Unix has no simple way of implementing
+give up its lock. Unix has no simple way of implementing
opportunistic locking, and currently Samba has no support for it.
Deny Modes
diff --git a/docs/textdocs/UNIX_INSTALL.txt b/docs/textdocs/UNIX_INSTALL.txt
index 8b430a98844..c189482ca41 100644
--- a/docs/textdocs/UNIX_INSTALL.txt
+++ b/docs/textdocs/UNIX_INSTALL.txt
@@ -315,7 +315,7 @@ codes of locking calls to tell clients that everything is OK.
The second class of locking is the "deny modes". These are set by an
application when it opens a file to determine what types of access
-should be allowed simultaneously with it's open. A client may ask for
+should be allowed simultaneously with its open. A client may ask for
DENY_NONE, DENY_READ, DENY_WRITE or DENY_ALL. There are also special
compatability modes called DENY_FCB and DENY_DOS.
--
cgit
From d684d276fbeb9a4f53840df8a47f6ca6ede8bd55 Mon Sep 17 00:00:00 2001
From: Jeremy Allison
Date: Fri, 5 Sep 1997 21:49:07 +0000
Subject: client.c: status.c: Ensure that myhostname is set so that
substitutions work. server.c: Sync up with main branch. Jermey
(jallison@whistle.com)
---
source/client/client.c | 6 ++++++
source/smbd/server.c | 3 ++-
source/utils/status.c | 4 ++--
3 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/source/client/client.c b/source/client/client.c
index 329956ce94b..4718db84ac0 100644
--- a/source/client/client.c
+++ b/source/client/client.c
@@ -34,6 +34,7 @@ pstring cd_path = "";
pstring service="";
pstring desthost="";
extern pstring myname;
+extern pstring myhostname;
pstring password = "";
pstring username="";
pstring workgroup="";
@@ -4625,6 +4626,11 @@ static void usage(char *pname)
DEBUG(3,("%s client started (version %s)\n",timestring(),VERSION));
+ if(!get_myname(myhostname,NULL))
+ {
+ DEBUG(0,("Failed to get my hostname.\n"));
+ }
+
if (!lp_load(servicesf,True)) {
fprintf(stderr, "Can't load %s - run testparm to debug it\n", servicesf);
}
diff --git a/source/smbd/server.c b/source/smbd/server.c
index 24dc8fb51f4..d4407269f0b 100644
--- a/source/smbd/server.c
+++ b/source/smbd/server.c
@@ -1532,12 +1532,13 @@ void open_file_shared(int fnum,int cnum,char *fname,int share_mode,int ofun,
if (strstr(fname,".+,;=[]."))
{
unix_ERR_class = ERRDOS;
- /* OS/2 Workplace shell fix - may be main code stream in a later release. */
+ /* OS/2 Workplace shell fix may be main code stream in a later release. */
#ifdef OS2_WPS_FIX
unix_ERR_code = ERRcannotopen;
#else /* OS2_WPS_FIX */
unix_ERR_code = ERROR_EAS_NOT_SUPPORTED;
#endif /* OS2_WPS_FIX */
+
return;
}
diff --git a/source/utils/status.c b/source/utils/status.c
index b439741e6c6..6fa85c0a630 100644
--- a/source/utils/status.c
+++ b/source/utils/status.c
@@ -188,13 +188,13 @@ locking version (was %d, should be %d).\n",fname,
}
}
+ get_myname(myhostname, NULL);
+
if (!lp_load(servicesf,False)) {
fprintf(stderr, "Can't load %s - run testparm to debug it\n", servicesf);
return (-1);
}
- get_myname(myhostname, NULL);
-
if (verbose) {
printf("using configfile = %s\n", servicesf);
printf("lockdir = %s\n", *lp_lockdir() ? lp_lockdir() : "NULL");
--
cgit
From 91f482026df92da804fbd0344c83807c9a2e775e Mon Sep 17 00:00:00 2001
From: Jeremy Allison
Date: Thu, 11 Sep 1997 00:19:26 +0000
Subject: locking.c: Fix to make slow share mode file 0666 instead of 0644.
Stoped smbstatus from reporting correct locks. nameelect.c: Luke's fix for
elections. namepacket.c: Removed iritating error message. nmblookup.c: Fixed
bug where status request went to random IP address. reply.c: Changed NTFS to
SAMBA in filename string. Jeremy (jallison@whistle.com)
---
source/locking/locking.c | 2 +-
source/nameelect.c | 2 +-
source/namepacket.c | 5 -----
source/smbd/reply.c | 2 +-
source/utils/nmblookup.c | 16 ++++++++++++----
5 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/source/locking/locking.c b/source/locking/locking.c
index f579a75a0bc..760d21a05d8 100644
--- a/source/locking/locking.c
+++ b/source/locking/locking.c
@@ -616,7 +616,7 @@ BOOL lock_share_entry(int cnum, uint32 dev, uint32 inode, share_lock_token *ptok
#ifdef SECURE_SHARE_MODES
fd = (share_lock_token)open(fname,O_RDWR|O_CREAT,0600);
#else /* SECURE_SHARE_MODES */
- fd = (share_lock_token)open(fname,O_RDWR|O_CREAT,0644);
+ fd = (share_lock_token)open(fname,O_RDWR|O_CREAT,0666);
#endif /* SECURE_SHARE_MODES */
umask(old_umask);
if(!become_user(cnum,Connections[cnum].vuid))
diff --git a/source/nameelect.c b/source/nameelect.c
index 06f3e870af1..4666b22588c 100644
--- a/source/nameelect.c
+++ b/source/nameelect.c
@@ -76,7 +76,7 @@ void check_master_browser(time_t t)
{
if (strequal(work->work_group, myworkgroup) && !AM_MASTER(work))
{
- if (lp_local_master())
+ if (lp_local_master() && lp_preferred_master())
{
/* potential master browser - not a master browser. force
becoming a master browser, hence the log message.
diff --git a/source/namepacket.c b/source/namepacket.c
index d60ef9f6ae2..44e449b8c2a 100644
--- a/source/namepacket.c
+++ b/source/namepacket.c
@@ -199,11 +199,6 @@ void reply_netbios_packet(struct packet_struct *p1,int trn_id,
p = *p1;
- if (recursion_available && lp_wins_server())
- {
- DEBUG(0,("reply_netbios_packet: r_a not to be used when not a WINS server\n"));
- }
-
switch (rcv_code)
{
case NMB_STATUS:
diff --git a/source/smbd/reply.c b/source/smbd/reply.c
index 773063131af..3ef37052dbe 100644
--- a/source/smbd/reply.c
+++ b/source/smbd/reply.c
@@ -268,7 +268,7 @@ int reply_tcon_and_X(char *inbuf,char *outbuf,int length,int bufsize)
}
else
{
- char *fsname = "NTFS";
+ char *fsname = "SAMBA";
char *p;
set_message(outbuf,3,3,True);
diff --git a/source/utils/nmblookup.c b/source/utils/nmblookup.c
index 582f4eb6db3..25c94dcd6a0 100644
--- a/source/utils/nmblookup.c
+++ b/source/utils/nmblookup.c
@@ -192,17 +192,25 @@ int main(int argc,char *argv[])
retries = 1;
}
- if (name_query(ServerFD,lookup,lookup_type,bcast,True,
+ if (name_query(ServerFD,lookup,lookup_type,bcast,True,
bcast_addr,&ip,NULL))
- {
- printf("%s %s\n",inet_ntoa(ip),lookup);
- }
+ {
+ printf("%s %s\n",inet_ntoa(ip),lookup);
+
+ /* We can only do find_status if the ip address returned
+ was valid - ie. name_query returned true.
+ */
if (find_status)
{
printf("Looking up status of %s\n",inet_ntoa(ip));
name_status(ServerFD,lookup,lookup_type,True,ip,NULL,NULL,NULL);
printf("\n");
}
+ }
+ else
+ {
+ printf("name_query failed to find name %s\n", lookup);
+ }
}
return(0);
--
cgit
From 87644499eac889a4c83c05f473883488cbdb710d Mon Sep 17 00:00:00 2001
From: Jeremy Allison
Date: Fri, 12 Sep 1997 16:31:51 +0000
Subject: Fixed bug where user connecting with guest username and no password
was not being seen as guest. Bug was introduced in previous patch.
Jeremy (jallison@whistle.com)
---
source/smbd/reply.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/source/smbd/reply.c b/source/smbd/reply.c
index 3ef37052dbe..228d8ad6692 100644
--- a/source/smbd/reply.c
+++ b/source/smbd/reply.c
@@ -459,6 +459,13 @@ int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize)
add_session_user(user);
+ /* Check if the given username was the guest user with no password.
+ We need to do this check after add_session_user() as that
+ call can potentially change the username (via map_user).
+ */
+
+ if(!guest && strequal(user,lp_guestaccount(-1)) && (*smb_apasswd == 0))
+ guest = True;
if (!guest && !(lp_security() == SEC_SERVER && server_validate(inbuf)) &&
!check_hosts_equiv(user))
--
cgit
From cfd4461be4522f1dd64d43e8a59f8baeed64f177 Mon Sep 17 00:00:00 2001
From: Jeremy Allison
Date: Mon, 15 Sep 1997 20:02:20 +0000
Subject: Keep consultants in sync.
---
docs/textdocs/Support.txt | 59 +++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 57 insertions(+), 2 deletions(-)
diff --git a/docs/textdocs/Support.txt b/docs/textdocs/Support.txt
index afffc2be505..6257872098a 100644
--- a/docs/textdocs/Support.txt
+++ b/docs/textdocs/Support.txt
@@ -29,11 +29,11 @@ Region Number of entries
----------------------------------------------------
AFRICA 2
AMERICA - CENTRAL & SOUTH 3
- AMERICA - USA 33
+ AMERICA - USA 35
ASIA 1
AUSTRALIA & NEW ZEALAND 18
CANADA 8
- EUROPE 33
+ EUROPE 34
MIDDLE EAST 1
AFRICA
@@ -223,6 +223,28 @@ To find out more about our company, look at our website:
http://www.acclaim.com
------------------------------------------------------------------------------
+------------------------------------------------------------------------------
+BAY AREA, BERKELEY CALIFORNIA - USA
+
+Vortex Technology Services
+
+2467 Warring St Suite 206, Berkeley CA 94704
+
+Phone/Fax : (510) 540-VTEX E-Mail: support@vtex.net
+ (510) 540-8839
+
+Contact: Paul Puey, Chief Network Consultant/Engineer
+
+Vortex Technology is a fast growing technical service company based in
+Berkeley, California. Our Co-founders are composed entirely of UC
+Berkeley engineering graduates with a broad range of skills in the
+technical consultation fields. We provide bay area companies with
+professional web site and database design, LAN and WAN consultation, and
+custom programming. We ourselves use a mixed NT / Linux Samba server
+environment in our office. We are very experienced with Samba
+administration as well as administration of UNIX and NT networks.
+------------------------------------------------------------------------------
+
------------------------------------------------------------------------------
CALIFORNIA - USA
@@ -628,6 +650,23 @@ US dollars per hour. Please contact us for more information on our
rates and services.
------------------------------------------------------------------------------
+------------------------------------------------------------------------------
+TEXAS - USA
+
+The Solutions Group
+P.O. Box 31400
+Houston, TX 77231-1400
+
+Voice: (713) 729-2602
+Fax: (713) 723-9387
+Email: chuckb@LinuxTX.com
+
+The Solutions Group provides support for Linux, Solaris, and SCO UNIX.
+We specialize in mixed environments using Samba. We are certified NT
+as well as UNIX specialists. We can provide onsite support in the
+Houston area and remote support in any other areas.
+------------------------------------------------------------------------------
+
------------------------------------------------------------------------------
UNITED STATES
@@ -1591,6 +1630,22 @@ Digital Unix
Macintosh
------------------------------------------------------------------------------
+------------------------------------------------------------------------------
+ROME - ITALY
+
+Company: Pantheon Srl
+ Via del Tritone 132
+ 00187 ROME - ITALY
+
+Phone/Fax: +39 6 47823666
+URL: http://www.pantheon.it
+
+Contact: Dario Centofanti
+
+Pantheon provide support for SaMBa and other TCP/IP applications running
+under Linux. We are also an internet provider.
+------------------------------------------------------------------------------
+
------------------------------------------------------------------------------
VICENZA - ITALY
--
cgit
From f8998b9dac5c86e5a12f730837aa7f24c24f1bf1 Mon Sep 17 00:00:00 2001
From: Jeremy Allison
Date: Wed, 17 Sep 1997 17:08:00 +0000
Subject: Ensuring malloced memory is bzero'd. Jeremy (jallison@whistle.com)
---
source/namedbname.c | 2 ++
source/namedbresp.c | 2 ++
source/namedbwork.c | 4 +++-
3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/source/namedbname.c b/source/namedbname.c
index c91541cc815..a45a749f140 100644
--- a/source/namedbname.c
+++ b/source/namedbname.c
@@ -486,6 +486,8 @@ struct name_record *add_netbios_entry(struct subnet_record *d,
return NULL;
}
+ bzero((char *)n->ip_flgs, sizeof(*n->ip_flgs) * n->num_ips);
+
make_nmb_name(&n->name,name,type,scope);
if ((n2 = find_name_search(&found_subnet, &n->name, search, new_only?ipzero:ip)))
diff --git a/source/namedbresp.c b/source/namedbresp.c
index 98f8ca774bc..86d7eddbd41 100644
--- a/source/namedbresp.c
+++ b/source/namedbresp.c
@@ -104,6 +104,8 @@ struct response_record *make_response_queue_record(enum state_type state,
if (!(n = (struct response_record *)malloc(sizeof(*n))))
return(NULL);
+ bzero((char *)n, sizeof(*n));
+
n->response_id = id;
n->state = state;
n->fd = fd;
diff --git a/source/namedbwork.c b/source/namedbwork.c
index 2982ffd3e78..a6260aab467 100644
--- a/source/namedbwork.c
+++ b/source/namedbwork.c
@@ -84,7 +84,8 @@ static struct work_record *make_workgroup(char *name)
work = (struct work_record *)malloc(sizeof(*work));
if (!work) return(NULL);
-
+ bzero((char *)work, sizeof(*work));
+
StrnCpy(work->work_group,name,sizeof(work->work_group)-1);
work->serverlist = NULL;
@@ -92,6 +93,7 @@ static struct work_record *make_workgroup(char *name)
SV_TYPE_POTENTIAL_BROWSER : 0 );
work->RunningElection = False;
work->ElectionCount = 0;
+ work->announce_interval = 0;
work->needelection = False;
work->needannounce = True;
work->mst_state = MST_POTENTIAL;
--
cgit
From c044da646c613e1e955072937fd7d0ded8b344ec Mon Sep 17 00:00:00 2001
From: Jeremy Allison
Date: Fri, 19 Sep 1997 00:48:54 +0000
Subject: Added South American consultant.
---
docs/textdocs/Support.txt | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/docs/textdocs/Support.txt b/docs/textdocs/Support.txt
index 6257872098a..0a5c41b1950 100644
--- a/docs/textdocs/Support.txt
+++ b/docs/textdocs/Support.txt
@@ -28,7 +28,7 @@ These are currently:
Region Number of entries
----------------------------------------------------
AFRICA 2
- AMERICA - CENTRAL & SOUTH 3
+ AMERICA - CENTRAL & SOUTH 4
AMERICA - USA 35
ASIA 1
AUSTRALIA & NEW ZEALAND 18
@@ -80,6 +80,25 @@ AMERICA - CENTRAL & SOUTH
=========================
+------------------------------------------------------------------------------
+ARGENTINA - SOUTH AMERICA
+
+Buenos Aires - Argentina
+
+Guillermo Sansovic
+Email: gui@usa.net
+Arkham Software
+Rivadavia 923 Piso 8
+1002 Buenos Aires
+Argentina
+
+Tel: + 54 1 345-0645
+
+At Arkham Software we have been working with Unix systems since 1986. We do
+intranets, software development and system integration. Our experience ith
+Samba dates from 1995.
+------------------------------------------------------------------------------
+
------------------------------------------------------------------------------
CHILE - SOUTH AMERICA
--
cgit
From c701db19e14d1b53103acbb8f7abe4c8bc2c3614 Mon Sep 17 00:00:00 2001
From: Jeremy Allison
Date: Mon, 22 Sep 1997 22:09:07 +0000
Subject: Makefile: Added glibc2 fixes for Linux. includes.h: Added glibc2
fixes for Linux. quotas.c: Added OSF1 fix. reply.c: Added fix from Ray Frush
to fix zero times for NT clients. Also added old
client session keepalives. Jeremy (jallison@whistle.com)
---
source/include/includes.h | 8 ++++++++
source/smbd/quotas.c | 20 ++++++++++++++++----
source/smbd/reply.c | 47 ++++++++++++++++++++++++++++++++++++++++-------
3 files changed, 64 insertions(+), 11 deletions(-)
diff --git a/source/include/includes.h b/source/include/includes.h
index a63f8f8597c..e66ceb2d70c 100644
--- a/source/include/includes.h
+++ b/source/include/includes.h
@@ -217,6 +217,14 @@ Here come some platform specific sections
#ifndef NO_ASMSIGNALH
#include
#endif
+#ifdef GLIBC2
+#define _LINUX_C_LIB_VERSION_MAJOR 6
+#include
+#include
+#include
+#include
+#include
+#endif
#define SIGNAL_CAST (__sighandler_t)
#define USE_GETCWD
#define USE_SETSID
diff --git a/source/smbd/quotas.c b/source/smbd/quotas.c
index d19d386e273..d4f746c9e36 100644
--- a/source/smbd/quotas.c
+++ b/source/smbd/quotas.c
@@ -373,22 +373,34 @@ try to get the disk space from disk quotas - OFS1 version
BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
{
uid_t user_id, euser_id;
- int r;
+ int r, save_errno;
struct dqblk D;
struct stat S;
euser_id = geteuid();
user_id = getuid();
- setreuid(euser_id, euser_id);
+ setreuid(euser_id, -1);
r= quotactl(path,QCMD(Q_GETQUOTA, USRQUOTA),euser_id,(char *) &D);
- if (setreuid(user_id, euser_id) == -1)
+ if (r)
+ save_errno = errno;
+
+ if (setreuid(user_id, -1) == -1)
DEBUG(5,("Unable to reset uid to %d\n", user_id));
*bsize = DEV_BSIZE;
if (r)
- return(False);
+ {
+ if (save_errno == EDQUOT) // disk quota exceeded
+ {
+ *dfree = 0;
+ *dsize = D.dqb_curblocks;
+ return (True);
+ }
+ else
+ return (False);
+ }
/* Use softlimit to determine disk space, except when it has been exceeded */
diff --git a/source/smbd/reply.c b/source/smbd/reply.c
index 228d8ad6692..a15185146da 100644
--- a/source/smbd/reply.c
+++ b/source/smbd/reply.c
@@ -65,19 +65,18 @@ int reply_special(char *inbuf,char *outbuf)
smb_setlen(outbuf,0);
- switch (msg_type)
- {
+ switch (msg_type) {
case 0x81: /* session request */
CVAL(outbuf,0) = 0x82;
CVAL(outbuf,3) = 0;
- if (name_len(inbuf+4) > 50)
- {
+ if (name_len(inbuf+4) > 50) {
DEBUG(0,("Invalid name length in session request\n"));
return(0);
}
name_extract(inbuf,4,name1);
name_extract(inbuf,4 + name_len(inbuf + 4),name2);
- DEBUG(2,("netbios connect: name1=%s name2=%s\n",name1,name2));
+ DEBUG(2,("netbios connect: name1=%s name2=%s\n",
+ name1,name2));
strcpy(remote_machine,name2);
trim_string(remote_machine," "," ");
@@ -97,12 +96,26 @@ int reply_special(char *inbuf,char *outbuf)
reopen_logs();
break;
+
+ case 0x89: /* session keepalive request
+ (some old clients produce this?) */
+ CVAL(outbuf,0) = 0x85;
+ CVAL(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 0x85: /* session keepalive */
default:
return(0);
}
- DEBUG(5,("%s init msg_type=0x%x msg_flags=0x%x\n",timestring(),msg_type,msg_flags));
+ DEBUG(5,("%s init msg_type=0x%x msg_flags=0x%x\n",
+ timestring(),msg_type,msg_flags));
return(outsize);
}
@@ -3532,11 +3545,31 @@ int reply_setattrE(char *inbuf,char *outbuf)
unix_times.actime = make_unix_date2(inbuf+smb_vwv3);
unix_times.modtime = make_unix_date2(inbuf+smb_vwv5);
+ /*
+ * Patch from Ray Frush
+ * Sometimes times are sent as zero - ignore them.
+ */
+
+ if ((unix_times.actime == 0) && (unix_times.modtime == 0))
+ {
+ /* Ignore request */
+ DEBUG(3,("%s reply_setattrE fnum=%d cnum=%d ignoring zero request - \
+not setting timestamps of 0\n",
+ timestring(), fnum,cnum,unix_times.actime,unix_times.modtime));
+ return(outsize);
+ }
+ else if ((unix_times.actime != 0) && (unix_times.modtime == 0))
+ {
+ /* set modify time = to access time if modify time was 0 */
+ unix_times.modtime = unix_times.actime;
+ }
+
/* Set the date on this file */
if(sys_utime(Files[fnum].name, &unix_times))
return(ERROR(ERRDOS,ERRnoaccess));
- DEBUG(3,("%s reply_setattrE fnum=%d cnum=%d\n",timestring(),fnum,cnum));
+ DEBUG(3,("%s reply_setattrE fnum=%d cnum=%d actime=%d modtime=%d\n",
+ timestring(), fnum,cnum,unix_times.actime,unix_times.modtime));
return(outsize);
}
--
cgit
From e8dd34b0d3ba704deff696c1683297536a494893 Mon Sep 17 00:00:00 2001
From: Andrew Tridgell
Date: Fri, 26 Sep 1997 12:39:45 +0000
Subject: This commit fixes the security hole due to buffer overflows.
The main fix is just a couple of lines long, but I have now also put
precautionary checks on a large number of other places in the code
where unchecked string copies were being performed. An exploit via one
of these copies is unlikely, but is is better to be safe.
I also added a routine to log possible exploit attempts using the code
that was posted for obtaining root access on a Samba server.
---
source/client/clientutil.c | 21 ++++----
source/include/local.h | 2 +
source/include/proto.h | 2 +
source/lib/system.c | 4 +-
source/lib/time.c | 4 +-
source/lib/username.c | 4 +-
source/lib/util.c | 114 +++++++++++++++++++++++++++++----------
source/libsmb/nmblib.c | 4 +-
source/locking/locking.c | 2 +-
source/nameannounce.c | 4 +-
source/namedbname.c | 8 +--
source/namedbsubnet.c | 4 +-
source/nameelect.c | 2 +-
source/namelogon.c | 6 +--
source/nmbd/nmbd.c | 22 ++++----
source/nmbsync.c | 4 +-
source/param/loadparm.c | 8 +--
source/printing/pcap.c | 4 +-
source/printing/printing.c | 36 ++++++-------
source/smbd/chgpasswd.c | 12 ++---
source/smbd/dir.c | 2 +-
source/smbd/ipc.c | 29 ++++++----
source/smbd/mangle.c | 8 +--
source/smbd/message.c | 14 ++---
source/smbd/pipes.c | 4 +-
source/smbd/reply.c | 131 +++++++++++++++++++++++++++------------------
source/smbd/server.c | 36 ++++++-------
source/smbd/trans2.c | 28 ++++++----
source/smbd/vt_mode.c | 12 ++---
source/utils/nmblookup.c | 6 +--
30 files changed, 320 insertions(+), 217 deletions(-)
diff --git a/source/client/clientutil.c b/source/client/clientutil.c
index b4f0849c5fe..1b59946ff5b 100644
--- a/source/client/clientutil.c
+++ b/source/client/clientutil.c
@@ -171,7 +171,8 @@ BOOL cli_send_session_request(char *inbuf, char *outbuf)
int len = 4;
/* send a session request (RFC 8002) */
- strcpy(dest,desthost);
+ fstrcpy(dest,desthost);
+
p = strchr(dest,'.');
if (p) *p = 0;
@@ -302,11 +303,11 @@ BOOL cli_send_login(char *inbuf, char *outbuf, BOOL start_session, BOOL use_setu
outbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
}
- strcpy(dev,"A:");
+ pstrcpy(dev,"A:");
if (connect_as_printer)
- strcpy(dev,"LPT1:");
+ pstrcpy(dev,"LPT1:");
if (connect_as_ipc)
- strcpy(dev,"IPC");
+ pstrcpy(dev,"IPC");
if (start_session && !cli_send_session_request(inbuf,outbuf))
@@ -438,7 +439,7 @@ BOOL cli_send_login(char *inbuf, char *outbuf, BOOL start_session, BOOL use_setu
{
fstring pword;
int passlen = strlen(pass)+1;
- strcpy(pword,pass);
+ fstrcpy(pword,pass);
#ifdef SMB_PASSWD
if (doencrypt && *pass) {
@@ -451,7 +452,7 @@ BOOL cli_send_login(char *inbuf, char *outbuf, BOOL start_session, BOOL use_setu
#endif
/* if in share level security then don't send a password now */
- if (!(sec_mode & 1)) {strcpy(pword, "");passlen=1;}
+ if (!(sec_mode & 1)) {fstrcpy(pword, "");passlen=1;}
/* send a session setup command */
bzero(outbuf,smb_size);
@@ -557,7 +558,7 @@ BOOL cli_send_login(char *inbuf, char *outbuf, BOOL start_session, BOOL use_setu
{
int passlen = strlen(pass)+1;
fstring pword;
- strcpy(pword,pass);
+ fstrcpy(pword,pass);
#ifdef SMB_PASSWD
if (doencrypt && *pass) {
@@ -568,7 +569,7 @@ BOOL cli_send_login(char *inbuf, char *outbuf, BOOL start_session, BOOL use_setu
/* if in user level security then don't send a password now */
if ((sec_mode & 1)) {
- strcpy(pword, ""); passlen=1;
+ fstrcpy(pword, ""); passlen=1;
}
set_message(outbuf,4,2 + strlen(service) + passlen + strlen(dev),True);
@@ -817,9 +818,9 @@ BOOL cli_open_sockets(int port)
}
else
{
- strcpy(service2,service);
+ pstrcpy(service2,service);
host = strtok(service2,"\\/");
- strcpy(desthost,host);
+ pstrcpy(desthost,host);
}
DEBUG(5,("Opening sockets\n"));
diff --git a/source/include/local.h b/source/include/local.h
index fc589d7ac0d..9548bf74b6b 100644
--- a/source/include/local.h
+++ b/source/include/local.h
@@ -42,6 +42,8 @@
#define WORDMAX 0xFFFF
+/* the maximum password length before we declare a likely attack */
+#define MAX_PASSWORD_LENGTH 200
/* separators for lists */
#define LIST_SEP " \t,;:\n\r"
diff --git a/source/include/proto.h b/source/include/proto.h
index 01afb7cad95..ffa2f251cca 100644
--- a/source/include/proto.h
+++ b/source/include/proto.h
@@ -976,6 +976,8 @@ void file_unlock(int fd);
BOOL is_myname(const char *s);
void set_remote_arch(enum remote_arch_types type);
enum remote_arch_types get_remote_arch();
+void fstrcpy(char *dest, char *src);
+void pstrcpy(char *dest, char *src);
/*The following definitions come from vt_mode.c */
diff --git a/source/lib/system.c b/source/lib/system.c
index 447a4f88aca..df24691512f 100644
--- a/source/lib/system.c
+++ b/source/lib/system.c
@@ -311,8 +311,8 @@ int sys_rename(char *from, char *to)
int rcode;
pstring zfrom, zto;
- strcpy (zfrom, dos_to_unix (from, False));
- strcpy (zto, dos_to_unix (to, False));
+ pstrcpy (zfrom, dos_to_unix (from, False));
+ pstrcpy (zto, dos_to_unix (to, False));
rcode = rename (zfrom, zto);
if (errno == EXDEV)
diff --git a/source/lib/time.c b/source/lib/time.c
index d16552b61e2..4f688d2214a 100644
--- a/source/lib/time.c
+++ b/source/lib/time.c
@@ -469,12 +469,12 @@ BOOL set_filetime(char *fname,time_t mtime)
****************************************************************************/
char *timestring(void )
{
- static char TimeBuf[100];
+ static fstring TimeBuf;
time_t t = time(NULL);
struct tm *tm = LocalTime(&t);
#ifdef NO_STRFTIME
- strcpy(TimeBuf, asctime(tm));
+ fstrcpy(TimeBuf, asctime(tm));
#elif defined(CLIX) || defined(CONVEX)
strftime(TimeBuf,100,"%m/%d/%y %I:%M:%S %p",tm);
#elif defined(AMPM)
diff --git a/source/lib/username.c b/source/lib/username.c
index b8d152c83fd..46b8f4cb332 100644
--- a/source/lib/username.c
+++ b/source/lib/username.c
@@ -62,7 +62,7 @@ void map_username(char *user)
if (strequal(user,last_from)) {
DEBUG(3,("Mapped user %s to %s\n",user,last_to));
- strcpy(user,last_to);
+ fstrcpy(user,last_to);
return;
}
@@ -173,7 +173,7 @@ struct passwd *Get_Pwnam(char *user,BOOL allow_change)
if (ret) return(ret);
if (allow_change)
- strcpy(user,user2);
+ fstrcpy(user,user2);
return(NULL);
}
diff --git a/source/lib/util.c b/source/lib/util.c
index 7f922def7e3..0c4999c789c 100644
--- a/source/lib/util.c
+++ b/source/lib/util.c
@@ -1079,7 +1079,7 @@ void unix_format(char *fname)
if (*fname == '/')
{
- strcpy(namecopy,fname);
+ pstrcpy(namecopy,fname);
strcpy(fname,".");
strcat(fname,namecopy);
}
@@ -1290,7 +1290,7 @@ void dos_clean_name(char *s)
pstring s1;
*p = 0;
- strcpy(s1,p+3);
+ pstrcpy(s1,p+3);
if ((p=strrchr(s,'\\')) != NULL)
*p = 0;
@@ -1328,7 +1328,7 @@ void unix_clean_name(char *s)
pstring s1;
*p = 0;
- strcpy(s1,p+3);
+ pstrcpy(s1,p+3);
if ((p=strrchr(s,'/')) != NULL)
*p = 0;
@@ -1355,7 +1355,7 @@ int ChDir(char *path)
DEBUG(3,("chdir to %s\n",path));
res = sys_chdir(path);
if (!res)
- strcpy(LastDir,path);
+ pstrcpy(LastDir,path);
return(res);
}
@@ -1515,7 +1515,7 @@ BOOL reduce_name(char *s,char *dir,BOOL widelinks)
/* remove any double slashes */
string_sub(s,"//","/");
- strcpy(basename,s);
+ pstrcpy(basename,s);
p = strrchr(basename,'/');
if (!p)
@@ -1585,12 +1585,12 @@ BOOL reduce_name(char *s,char *dir,BOOL widelinks)
if (relative)
{
if (newname[l] == '/')
- strcpy(s,newname + l + 1);
+ pstrcpy(s,newname + l + 1);
else
- strcpy(s,newname+l);
+ pstrcpy(s,newname+l);
}
else
- strcpy(s,newname);
+ pstrcpy(s,newname);
}
ChDir(wd);
@@ -1614,10 +1614,10 @@ static void expand_one(char *Mask,int len)
int lfill = (len+1) - strlen(Mask);
int l1= (p1 - Mask);
pstring tmp;
- strcpy(tmp,Mask);
+ pstrcpy(tmp,Mask);
memset(tmp+l1,'?',lfill);
- strcpy(tmp + l1 + lfill,Mask + l1 + 1);
- strcpy(Mask,tmp);
+ pstrcpy(tmp + l1 + lfill,Mask + l1 + 1);
+ pstrcpy(Mask,tmp);
}
}
@@ -1641,20 +1641,20 @@ void expand_mask(char *Mask,BOOL doext)
filename_dos(Mask,filepart);
- strcpy(mbeg,filepart);
+ pstrcpy(mbeg,filepart);
if ((p1 = strchr(mbeg,'.')) != NULL)
{
hasdot = True;
*p1 = 0;
p1++;
- strcpy(mext,p1);
+ pstrcpy(mext,p1);
}
else
{
strcpy(mext,"");
if (strlen(mbeg) > 8)
{
- strcpy(mext,mbeg + 8);
+ pstrcpy(mext,mbeg + 8);
mbeg[8] = 0;
}
}
@@ -1672,7 +1672,7 @@ void expand_mask(char *Mask,BOOL doext)
if (*mext)
expand_one(mext,3);
- strcpy(Mask,dirpart);
+ pstrcpy(Mask,dirpart);
if (*dirpart || absolute) strcat(Mask,"\\");
strcat(Mask,mbeg);
strcat(Mask,".");
@@ -1773,7 +1773,7 @@ void make_dir_struct(char *buf,char *mask,char *fname,unsigned int size,int mode
char *p;
pstring mask2;
- strcpy(mask2,mask);
+ pstrcpy(mask2,mask);
if ((mode & aDIR) != 0)
size = 0;
@@ -2421,7 +2421,12 @@ BOOL string_init(char **dest,char *src)
}
else
{
- *dest = (char *)malloc(l+1);
+ (*dest) = (char *)malloc(l+1);
+ if ((*dest) == NULL) {
+ DEBUG(0,("Out of memory in string_init\n"));
+ return False;
+ }
+
strcpy(*dest,src);
}
return(True);
@@ -2593,25 +2598,25 @@ BOOL mask_match(char *str, char *regexp, int case_sig,BOOL trans2)
DEBUG(5,("mask_match str=<%s> regexp=<%s>, case_sig = %d\n", p2, p1, case_sig));
if (trans2) {
- strcpy(ebase,p1);
- strcpy(sbase,p2);
+ fstrcpy(ebase,p1);
+ fstrcpy(sbase,p2);
} else {
if ((p=strrchr(p1,'.'))) {
*p = 0;
- strcpy(ebase,p1);
- strcpy(eext,p+1);
+ fstrcpy(ebase,p1);
+ fstrcpy(eext,p+1);
} else {
- strcpy(ebase,p1);
+ fstrcpy(ebase,p1);
eext[0] = 0;
}
if (!strequal(p2,".") && !strequal(p2,"..") && (p=strrchr(p2,'.'))) {
*p = 0;
- strcpy(sbase,p2);
- strcpy(sext,p+1);
+ fstrcpy(sbase,p2);
+ fstrcpy(sext,p+1);
} else {
- strcpy(sbase,p2);
- strcpy(sext,"");
+ fstrcpy(sbase,p2);
+ fstrcpy(sext,"");
}
}
@@ -2927,7 +2932,7 @@ BOOL get_myname(char *my_name,struct in_addr *ip)
char *p = strchr(hostname,'.');
if (p) *p = 0;
- strcpy(my_name,hostname);
+ fstrcpy(my_name,hostname);
}
if (ip)
@@ -3295,7 +3300,7 @@ char *client_addr(void)
return addr_buf;
}
- strcpy(addr_buf,(char *)inet_ntoa(sockin->sin_addr));
+ fstrcpy(addr_buf,(char *)inet_ntoa(sockin->sin_addr));
global_client_addr_done = True;
return addr_buf;
@@ -3552,7 +3557,7 @@ char *readdirname(void *p)
{
static pstring buf;
- strcpy(buf, dname);
+ pstrcpy(buf, dname);
unix_to_dos(buf, True);
dname = buf;
}
@@ -3907,3 +3912,54 @@ enum remote_arch_types get_remote_arch()
{
return ra_type;
}
+
+
+/*******************************************************************
+safe string copy into a fstring
+********************************************************************/
+void fstrcpy(char *dest, char *src)
+{
+ int maxlength = sizeof(fstring) - 1;
+ if (!dest) {
+ DEBUG(0,("ERROR: NULL dest in fstrcpy\n"));
+ return;
+ }
+
+ if (!src) {
+ *dest = 0;
+ return;
+ }
+
+ while (maxlength-- && *src)
+ *dest++ = *src++;
+ *dest = 0;
+ if (*src) {
+ DEBUG(0,("ERROR: string overflow by %d in fstrcpy\n",
+ strlen(src)));
+ }
+}
+
+/*******************************************************************
+safe string copy into a pstring
+********************************************************************/
+void pstrcpy(char *dest, char *src)
+{
+ int maxlength = sizeof(pstring) - 1;
+ if (!dest) {
+ DEBUG(0,("ERROR: NULL dest in pstrcpy\n"));
+ return;
+ }
+
+ if (!src) {
+ *dest = 0;
+ return;
+ }
+
+ while (maxlength-- && *src)
+ *dest++ = *src++;
+ *dest = 0;
+ if (*src) {
+ DEBUG(0,("ERROR: string overflow by %d in pstrcpy\n",
+ strlen(src)));
+ }
+}
diff --git a/source/libsmb/nmblib.c b/source/libsmb/nmblib.c
index bc967bdacb4..29b54a708bc 100644
--- a/source/libsmb/nmblib.c
+++ b/source/libsmb/nmblib.c
@@ -616,10 +616,10 @@ static int build_dgram(char *buf,struct packet_struct *p)
******************************************************************/
void make_nmb_name(struct nmb_name *n,char *name,int type,char *this_scope)
{
- strcpy(n->name,name);
+ fstrcpy(n->name,name);
strupper(n->name);
n->name_type = type;
- strcpy(n->scope,this_scope);
+ fstrcpy(n->scope,this_scope);
}
diff --git a/source/locking/locking.c b/source/locking/locking.c
index 760d21a05d8..c2a06cac75c 100644
--- a/source/locking/locking.c
+++ b/source/locking/locking.c
@@ -108,7 +108,7 @@ BOOL start_share_mode_mgmt(void)
{
pstring shmem_file_name;
- strcpy(shmem_file_name,lp_lockdir());
+ pstrcpy(shmem_file_name,lp_lockdir());
if (!directory_exist(shmem_file_name,NULL))
mkdir(shmem_file_name,0755);
trim_string(shmem_file_name,"","/");
diff --git a/source/nameannounce.c b/source/nameannounce.c
index 684ef412581..84e3ad3fa77 100644
--- a/source/nameannounce.c
+++ b/source/nameannounce.c
@@ -174,11 +174,11 @@ void do_announce_host(int command,
SSVAL(p,27,BROWSER_ELECTION_VERSION);
SSVAL(p,29,BROWSER_CONSTANT); /* browse signature */
- strcpy(p+31,server_comment);
+ pstrcpy(p+31,server_comment);
p += 31;
p = skip_string(p,1);
- debug_browse_data(outbuf, PTR_DIFF(p,outbuf));
+ debug_browse_data(outbuf, PTR_DIFF(p,outbuf));
/* send the announcement */
send_mailslot_reply(False,BROWSE_MAILSLOT,ClientDGRAM,outbuf,
diff --git a/source/namedbname.c b/source/namedbname.c
index a45a749f140..51571d786a8 100644
--- a/source/namedbname.c
+++ b/source/namedbname.c
@@ -226,11 +226,11 @@ void dump_names(void)
if(lp_wins_support() == False || wins_subnet == 0)
return;
- strcpy(fname,lp_lockdir());
+ fstrcpy(fname,lp_lockdir());
trim_string(fname,NULL,"/");
strcat(fname,"/");
strcat(fname,WINS_LIST);
- strcpy(fnamenew,fname);
+ fstrcpy(fnamenew,fname);
strcat(fnamenew,".");
f = fopen(fnamenew,"w");
@@ -306,7 +306,7 @@ void load_netbios_names(void)
if (!d) return;
- strcpy(fname,lp_lockdir());
+ fstrcpy(fname,lp_lockdir());
trim_string(fname,NULL,"/");
strcat(fname,"/");
strcat(fname,WINS_LIST);
@@ -366,7 +366,7 @@ void load_netbios_names(void)
nb_flags_str[strlen(nb_flags_str)-1] = '\0';
/* netbios name. # divides the name from the type (hex): netbios#xx */
- strcpy(name,name_str);
+ pstrcpy(name,name_str);
p = strchr(name,'#');
diff --git a/source/namedbsubnet.c b/source/namedbsubnet.c
index 6364ebba543..4f0b647996d 100644
--- a/source/namedbsubnet.c
+++ b/source/namedbsubnet.c
@@ -308,11 +308,11 @@ void write_browse_list(time_t t)
dump_names();
dump_workgroups();
- strcpy(fname,lp_lockdir());
+ pstrcpy(fname,lp_lockdir());
trim_string(fname,NULL,"/");
strcat(fname,"/");
strcat(fname,SERVER_LIST);
- strcpy(fnamenew,fname);
+ pstrcpy(fnamenew,fname);
strcat(fnamenew,".");
f = fopen(fnamenew,"w");
diff --git a/source/nameelect.c b/source/nameelect.c
index 4666b22588c..5c156a312ed 100644
--- a/source/nameelect.c
+++ b/source/nameelect.c
@@ -182,7 +182,7 @@ void send_election(struct subnet_record *d, char *group,uint32 criterion,
SIVAL(p,1,criterion);
SIVAL(p,5,timeup*1000); /* ms - despite the spec */
p += 13;
- strcpy(p,name);
+ pstrcpy(p,name);
strupper(p);
p = skip_string(p,1);
diff --git a/source/namelogon.c b/source/namelogon.c
index 1c118c85418..1f57139d56a 100644
--- a/source/namelogon.c
+++ b/source/namelogon.c
@@ -74,7 +74,7 @@ void process_logon_packet(struct packet_struct *p,char *buf,int len)
token = SVAL(tmp,3);
reply_code = 0x6;
- strcpy(reply_name,myname);
+ fstrcpy(reply_name,myname);
strupper(reply_name);
add_slashes = True;
DEBUG(3,("Domain login request from %s(%s) user=%s token=%x\n",
@@ -87,11 +87,11 @@ void process_logon_packet(struct packet_struct *p,char *buf,int len)
logname = skip_string(machine,1);
token = SVAL(skip_string(logname,1),0);
- strcpy(reply_name,lp_domain_controller());
+ fstrcpy(reply_name,lp_domain_controller());
if (!*reply_name)
{
/* oo! no domain controller. must be us, then */
- strcpy(reply_name,myname);
+ fstrcpy(reply_name,myname);
reply_code = 0xC;
}
else
diff --git a/source/nmbd/nmbd.c b/source/nmbd/nmbd.c
index 925f975ffef..3f0279908da 100644
--- a/source/nmbd/nmbd.c
+++ b/source/nmbd/nmbd.c
@@ -121,7 +121,7 @@ static BOOL dump_core(void)
{
char *p;
pstring dname;
- strcpy(dname,debugf);
+ pstrcpy(dname,debugf);
if ((p=strrchr(dname,'/'))) *p=0;
strcat(dname,"/corefiles");
mkdir(dname,0700);
@@ -188,10 +188,10 @@ BOOL reload_services(BOOL test)
if (lp_loaded())
{
pstring fname;
- strcpy(fname,lp_configfile());
+ pstrcpy(fname,lp_configfile());
if (file_exist(fname,NULL) && !strcsequal(fname,servicesf))
{
- strcpy(servicesf,fname);
+ pstrcpy(servicesf,fname);
test = False;
}
}
@@ -276,7 +276,7 @@ static void load_hosts_file(char *fname)
if (strchr(flags,'M')) {
source = SELF;
- strcpy(myname,name);
+ pstrcpy(myname,name);
}
ipaddr = *interpret_addr2(ip);
@@ -371,7 +371,7 @@ static BOOL init_structs()
pstring nbname;
if (! *myname) {
- strcpy(myname,myhostname);
+ fstrcpy(myname,myhostname);
p = strchr(myname,'.');
if (p) *p = 0;
}
@@ -422,7 +422,7 @@ static BOOL init_structs()
/* Terminate name list */
my_netbios_names[namecount++]=NULL;
- strcpy(local_machine,myname);
+ fstrcpy(local_machine,myname);
trim_string(local_machine," "," ");
p = strchr(local_machine,' ');
if (p)
@@ -501,7 +501,7 @@ static void usage(char *pname)
strncpy(pidFile, optarg, sizeof(pidFile));
break;
case 's':
- strcpy(servicesf,optarg);
+ pstrcpy(servicesf,optarg);
break;
case 'N':
case 'B':
@@ -511,17 +511,17 @@ static void usage(char *pname)
DEBUG(0,("Obsolete option '%c' used\n",opt));
break;
case 'H':
- strcpy(host_file,optarg);
+ pstrcpy(host_file,optarg);
break;
case 'n':
- strcpy(myname,optarg);
+ pstrcpy(myname,optarg);
strupper(myname);
break;
case 'l':
sprintf(debugf,"%s.nmb",optarg);
break;
case 'i':
- strcpy(scope,optarg);
+ pstrcpy(scope,optarg);
strupper(scope);
break;
case 'D':
@@ -564,7 +564,7 @@ static void usage(char *pname)
reload_services(True);
- strcpy(myworkgroup, lp_workgroup());
+ pstrcpy(myworkgroup, lp_workgroup());
if (strequal(myworkgroup,"*")) {
DEBUG(0,("ERROR: a workgroup name of * is no longer supported\n"));
diff --git a/source/nmbsync.c b/source/nmbsync.c
index f2161f631af..de2f7aa00f1 100644
--- a/source/nmbsync.c
+++ b/source/nmbsync.c
@@ -82,7 +82,7 @@ static BOOL add_info(struct subnet_record *d, struct work_record *work, int serv
SIVAL(p,0,servertype);
p += 4;
- strcpy(p, work->work_group);
+ pstrcpy(p, work->work_group);
p = skip_string(p,1);
if (cli_call_api(PTR_DIFF(p,param),0, 8,BUFFER_SIZE - SAFETY_MARGIN,
@@ -162,7 +162,7 @@ void sync_browse_lists(struct subnet_record *d, struct work_record *work,
name, work->work_group, inet_ntoa(ip)));
strcpy(workgroup,work->work_group);
- strcpy(desthost,name);
+ fstrcpy(desthost,name);
dest_ip = ip;
if (zero_ip(dest_ip)) return;
diff --git a/source/param/loadparm.c b/source/param/loadparm.c
index ad9bf83886d..510a661dc39 100644
--- a/source/param/loadparm.c
+++ b/source/param/loadparm.c
@@ -1382,7 +1382,7 @@ static void add_to_file_list(char *fname)
{
pstring n2;
- strcpy(n2,fname);
+ pstrcpy(n2,fname);
standard_sub_basic(n2);
f->modtime = file_modtime(n2);
}
@@ -1402,7 +1402,7 @@ BOOL lp_file_list_changed(void)
pstring n2;
time_t mod_time;
- strcpy(n2,f->name);
+ pstrcpy(n2,f->name);
standard_sub_basic(n2);
DEBUG(6,("file %s -> %s last mod_time: %s\n",
@@ -1532,7 +1532,7 @@ handle the include operation
static BOOL handle_include(char *pszParmValue,char **ptr)
{
pstring fname;
- strcpy(fname,pszParmValue);
+ pstrcpy(fname,pszParmValue);
add_to_file_list(fname);
@@ -2025,7 +2025,7 @@ BOOL lp_load(char *pszFname,BOOL global_only)
init_globals();
- strcpy(n2,pszFname);
+ pstrcpy(n2,pszFname);
standard_sub_basic(n2);
/* We get sections first, so have to start 'behind' to make up */
diff --git a/source/printing/pcap.c b/source/printing/pcap.c
index 549ebcd70df..65195ab1af6 100644
--- a/source/printing/pcap.c
+++ b/source/printing/pcap.c
@@ -358,8 +358,8 @@ void pcap_printer_fn(void (*fn)())
if (strlen(p) <= 8 && strlen(p)>strlen(name) && !has_punctuation)
{
- if (!*comment) strcpy(comment,name);
- strcpy(name,p);
+ if (!*comment) pstrcpy(comment,name);
+ pstrcpy(name,p);
continue;
}
diff --git a/source/printing/printing.c b/source/printing/printing.c
index c83d2169891..51fd3a992eb 100644
--- a/source/printing/printing.c
+++ b/source/printing/printing.c
@@ -85,7 +85,7 @@ static char *build_print_command(int cnum, char *command, char *syscmd, char *fi
strcat(filename,filename1);
}
else
- strcpy(filename,filename1);
+ pstrcpy(filename,filename1);
string_sub(syscmd, "%s", filename);
}
@@ -258,7 +258,7 @@ static BOOL parse_lpq_bsd(char *line,print_queue_struct *buf,BOOL first)
if (p)
{
strcpy(tmp,p+1);
- strcpy(tok[FILETOK],tmp);
+ fstrcpy(tok[FILETOK],tmp);
}
}
@@ -404,8 +404,8 @@ A long spool-path will just waste significant chars of the file name.
char *p = strrchr(tok[LPRNG_FILETOK],'/');
if (p)
{
- strcpy(tmp,p+1);
- strcpy(tok[LPRNG_FILETOK],tmp);
+ fstrcpy(tmp,p+1);
+ fstrcpy(tok[LPRNG_FILETOK],tmp);
}
}
@@ -472,8 +472,8 @@ static BOOL parse_lpq_aix(char *line,print_queue_struct *buf,BOOL first)
char *p = strrchr(tok[2],'/');
if (p)
{
- strcpy(tmp,p+1);
- strcpy(tok[2],tmp);
+ fstrcpy(tmp,p+1);
+ fstrcpy(tok[2],tmp);
}
}
@@ -506,8 +506,8 @@ static BOOL parse_lpq_aix(char *line,print_queue_struct *buf,BOOL first)
char *p = strrchr(tok[4],'/');
if (p)
{
- strcpy(tmp,p+1);
- strcpy(tok[4],tmp);
+ fstrcpy(tmp,p+1);
+ fstrcpy(tok[4],tmp);
}
}
@@ -666,8 +666,8 @@ static BOOL parse_lpq_sysv(char *line,print_queue_struct *buf,BOOL first)
if ((p=strchr(tok[2],'!')))
{
string tmp;
- strcpy(tmp,p+1);
- strcpy(tok[2],tmp);
+ fstrcpy(tmp,p+1);
+ fstrcpy(tok[2],tmp);
}
@@ -731,8 +731,8 @@ static BOOL parse_lpq_qnx(char *line,print_queue_struct *buf,BOOL first)
char *p = strrchr(tok[6],'/');
if (p)
{
- strcpy(tmp,p+1);
- strcpy(tok[6],tmp);
+ fstrcpy(tmp,p+1);
+ fstrcpy(tok[6],tmp);
}
}
@@ -795,8 +795,8 @@ static BOOL parse_lpq_plp(char *line,print_queue_struct *buf,BOOL first)
char *p = strrchr(tok[6],'/');
if (p)
{
- strcpy(tmp,p+1);
- strcpy(tok[6],tmp);
+ fstrcpy(tmp,p+1);
+ fstrcpy(tok[6],tmp);
}
}
@@ -863,7 +863,7 @@ static BOOL parse_lpq_entry(int snum,char *line,
/* change guest entries to the current logged in user to make
them appear deletable to windows */
if (sesssetup_user[0] && strequal(buf->user,lp_guestaccount(snum)))
- strcpy(buf->user,sesssetup_user);
+ pstrcpy(buf->user,sesssetup_user);
}
#endif
@@ -940,7 +940,7 @@ int get_printqueue(int snum,int cnum,print_queue_struct **queue,
return(0);
}
- strcpy(syscmd,lpq_command);
+ pstrcpy(syscmd,lpq_command);
string_sub(syscmd,"%p",printername);
standard_sub(cnum,syscmd);
@@ -1031,7 +1031,7 @@ void del_printqueue(int cnum,int snum,int jobid)
sprintf(jobstr,"%d",jobid);
- strcpy(syscmd,lprm_command);
+ pstrcpy(syscmd,lprm_command);
string_sub(syscmd,"%p",printername);
string_sub(syscmd,"%j",jobstr);
standard_sub(cnum,syscmd);
@@ -1069,7 +1069,7 @@ void status_printjob(int cnum,int snum,int jobid,int status)
sprintf(jobstr,"%d",jobid);
- strcpy(syscmd,lpstatus_command);
+ pstrcpy(syscmd,lpstatus_command);
string_sub(syscmd,"%p",printername);
string_sub(syscmd,"%j",jobstr);
standard_sub(cnum,syscmd);
diff --git a/source/smbd/chgpasswd.c b/source/smbd/chgpasswd.c
index 6063f2aac8a..bed81138b24 100644
--- a/source/smbd/chgpasswd.c
+++ b/source/smbd/chgpasswd.c
@@ -212,8 +212,8 @@ static int expect(int master,char *expected,char *buf)
{
pstring s1,s2;
- strcpy(s1,buf);
- strcpy(s2,expected);
+ pstrcpy(s1,buf);
+ pstrcpy(s2,expected);
if (do_match(s1, s2, False))
return(True);
}
@@ -364,11 +364,11 @@ BOOL chgpasswd(char *name,char *oldpass,char *newpass)
}
#if (defined(PASSWD_PROGRAM) && defined(PASSWD_CHAT))
- strcpy(passwordprogram,PASSWD_PROGRAM);
- strcpy(chatsequence,PASSWD_CHAT);
+ pstrcpy(passwordprogram,PASSWD_PROGRAM);
+ pstrcpy(chatsequence,PASSWD_CHAT);
#else
- strcpy(passwordprogram,lp_passwd_program());
- strcpy(chatsequence,lp_passwd_chat());
+ pstrcpy(passwordprogram,lp_passwd_program());
+ pstrcpy(chatsequence,lp_passwd_chat());
#endif
if (!*chatsequence) {
diff --git a/source/smbd/dir.c b/source/smbd/dir.c
index 06ee6ae8ed7..567bc14424e 100644
--- a/source/smbd/dir.c
+++ b/source/smbd/dir.c
@@ -461,7 +461,7 @@ BOOL get_dir_entry(int cnum,char *mask,int dirtype,char *fname,int *size,int *mo
matched = False;
- strcpy(filename,dname);
+ pstrcpy(filename,dname);
if ((strcmp(filename,mask) == 0) ||
(name_map_mangle(filename,True,SNUM(cnum)) &&
diff --git a/source/smbd/ipc.c b/source/smbd/ipc.c
index 55e293d7ffd..9aaf03e6c4f 100644
--- a/source/smbd/ipc.c
+++ b/source/smbd/ipc.c
@@ -774,7 +774,7 @@ static int get_server_info(uint32 servertype,
pstring line;
BOOL local_list_only;
- strcpy(fname,lp_lockdir());
+ pstrcpy(fname,lp_lockdir());
trim_string(fname,NULL,"/");
strcat(fname,"/");
strcat(fname,SERVER_LIST);
@@ -1363,7 +1363,7 @@ static BOOL api_SetUserPassword(int cnum,uint16 vuid, char *param,char *data,
fstring user;
fstring pass1,pass2;
- strcpy(user,p);
+ fstrcpy(user,p);
p = skip_string(p,1);
@@ -1698,14 +1698,14 @@ static BOOL api_RNetServerGetInfo(int cnum,uint16 vuid, char *param,char *data,
pstring comment;
uint32 servertype= lp_default_server_announce();
- strcpy(comment,lp_serverstring());
+ pstrcpy(comment,lp_serverstring());
if ((count=get_server_info(SV_TYPE_ALL,&servers,myworkgroup))>0) {
for (i=0;i 0)
{
@@ -2043,9 +2043,9 @@ static BOOL api_RNetUserGetInfo(int cnum,uint16 vuid, char *param,char *data,
strcpy(p2,"UserComment");
p2 = skip_string(p2,1);
- /* EEK! the cifsrap.txt doesn't have this in!!!! */
+ /* EEK! the cifsrap.txt doesn't have this in!!!! */
SIVAL(p,usri11_full_name,PTR_DIFF(p2,p)); /* full name */
- strcpy(p2,vuser->real_name); /* simeon */
+ strcpy(p2,vuser->real_name); /* simeon */
p2 = skip_string(p2,1);
}
@@ -2062,7 +2062,7 @@ static BOOL api_RNetUserGetInfo(int cnum,uint16 vuid, char *param,char *data,
else
{
#if (defined(NETGROUP) && defined(AUTOMOUNT))
- strcpy(p2, vuser->home_share);
+ strcpy(p2, vuser->home_share);
#else
strcpy(p2,"\\\\%L\\%U");
#endif
@@ -2461,7 +2461,8 @@ static void fill_printdest_info(int cnum, int snum, int uLevel,
struct pack_desc* desc)
{
char buf[100];
- strcpy(buf,SERVICE(snum));
+ strncpy(buf,SERVICE(snum),sizeof(buf)-1);
+ buf[sizeof(buf)-1] = 0;
strupper(buf);
if (uLevel <= 1) {
PACKS(desc,"B9",buf); /* szName */
@@ -3018,7 +3019,11 @@ int reply_trans(char *inbuf,char *outbuf)
int dsoff = SVAL(inbuf,smb_vwv12);
int suwcnt = CVAL(inbuf,smb_vwv13);
- StrnCpy(name,smb_buf(inbuf),sizeof(name)-1);
+ fstrcpy(name,smb_buf(inbuf));
+
+ if (dscnt > tdscnt || pscnt > tpscnt) {
+ exit_server("invalid trans parameters\n");
+ }
if (tdscnt)
{
@@ -3080,6 +3085,10 @@ int reply_trans(char *inbuf,char *outbuf)
pscnt += pcnt;
dscnt += dcnt;
+ if (dscnt > tdscnt || pscnt > tpscnt) {
+ exit_server("invalid trans parameters\n");
+ }
+
if (pcnt)
memcpy(params+pdisp,smb_base(inbuf)+poff,pcnt);
if (dcnt)
diff --git a/source/smbd/mangle.c b/source/smbd/mangle.c
index a08402a85ea..a964f4a5c73 100644
--- a/source/smbd/mangle.c
+++ b/source/smbd/mangle.c
@@ -269,7 +269,7 @@ BOOL check_mangled_stack(char *s)
}
if (check_extension && !strchr(mangled_stack[i],'.'))
{
- strcpy(tmpname,mangled_stack[i]);
+ pstrcpy(tmpname,mangled_stack[i]);
strcat(tmpname,extension);
mangle_name_83(tmpname);
if (strequal(tmpname,s))
@@ -303,7 +303,7 @@ static char *map_filename(char *s, /* This is null terminated */
pstring pat;
StrnCpy(pat, pattern, len); /* Get pattern into a proper string! */
- strcpy(matching_bit,""); /* Match but no star gets this. */
+ pstrcpy(matching_bit,""); /* Match but no star gets this. */
pp = pat; /* Initialise the pointers. */
sp = s;
if ((len == 1) && (*pattern == '*')) {
@@ -442,7 +442,7 @@ static void do_fwd_mangled_map(char *s, char *MangledMap)
continue; /* Always check for the end. */
}
if (*end == '*') {
- strcpy(np, match_string);
+ pstrcpy(np, match_string);
np += strlen(match_string);
end++; /* Skip the '*' */
while ((*end) /* Not the end of string. */
@@ -456,7 +456,7 @@ static void do_fwd_mangled_map(char *s, char *MangledMap)
}
*np++ = '\0'; /* NULL terminate it. */
DEBUG(5,("End of second in pair '%s'\n", end));
- strcpy(s, new_string); /* Substitute with the new name. */
+ pstrcpy(s, new_string); /* Substitute with the new name. */
DEBUG(5,("s is now '%s'\n", s));
}
start = end; /* Skip a bit which cannot be wanted */
diff --git a/source/smbd/message.c b/source/smbd/message.c
index 93a2d9d850a..64253932abb 100644
--- a/source/smbd/message.c
+++ b/source/smbd/message.c
@@ -54,7 +54,7 @@ static void msg_deliver(void)
/* put it in a temporary file */
sprintf(s,"%s/msg.XXXXXX",tmpdir());
- strcpy(name,(char *)mktemp(s));
+ fstrcpy(name,(char *)mktemp(s));
fd = open(name,O_WRONLY|O_CREAT|O_TRUNC|O_EXCL,0600);
if (fd == -1) {
@@ -74,7 +74,7 @@ static void msg_deliver(void)
/* run the command */
if (*lp_msg_command())
{
- strcpy(s,lp_msg_command());
+ pstrcpy(s,lp_msg_command());
string_sub(s,"%s",name);
string_sub(s,"%f",msgfrom);
string_sub(s,"%t",msgto);
@@ -108,8 +108,8 @@ int reply_sends(char *inbuf,char *outbuf)
dest = skip_string(orig,1)+1;
msg = skip_string(dest,1)+1;
- strcpy(msgfrom,orig);
- strcpy(msgto,dest);
+ fstrcpy(msgfrom,orig);
+ fstrcpy(msgto,dest);
len = SVAL(msg,0);
len = MIN(len,1600-msgpos);
@@ -143,10 +143,10 @@ int reply_sendstrt(char *inbuf,char *outbuf)
orig = smb_buf(inbuf)+1;
dest = skip_string(orig,1)+1;
- strcpy(msgfrom,orig);
- strcpy(msgto,dest);
+ fstrcpy(msgfrom,orig);
+ fstrcpy(msgto,dest);
- DEBUG(3,("%s SMBsendstrt (from %s to %s)\n",timestring(),orig,dest));
+ DEBUG(3,("%s SMBsendstrt (from %s to %s)\n",timestring(),msgfrom,msgto));
return(outsize);
}
diff --git a/source/smbd/pipes.c b/source/smbd/pipes.c
index afab7e1d911..feb8d91a5b0 100644
--- a/source/smbd/pipes.c
+++ b/source/smbd/pipes.c
@@ -87,7 +87,7 @@ int reply_open_pipe_and_X(char *inbuf,char *outbuf,int length,int bufsize)
BOOL bad_path = False;
/* XXXX we need to handle passed times, sattr and flags */
- strcpy(fname,smb_buf(inbuf));
+ pstrcpy(fname,smb_buf(inbuf));
/* If the name doesn't start \PIPE\ then this is directed */
/* at a mailslot or something we really, really don't understand, */
@@ -98,7 +98,7 @@ int reply_open_pipe_and_X(char *inbuf,char *outbuf,int length,int bufsize)
DEBUG(4,("Opening pipe %s.\n", fname));
/* Strip \PIPE\ off the name. */
- strcpy(fname,smb_buf(inbuf) + PIPELEN);
+ pstrcpy(fname,smb_buf(inbuf) + PIPELEN);
/* See if it is one we want to handle. */
for( i = 0; known_pipes[i] ; i++ )
diff --git a/source/smbd/reply.c b/source/smbd/reply.c
index a15185146da..4235e7725e9 100644
--- a/source/smbd/reply.c
+++ b/source/smbd/reply.c
@@ -48,6 +48,18 @@ a packet to ensure chaining works correctly */
#define GETFNUM(buf,where) (chain_fnum!= -1?chain_fnum:SVAL(buf,where))
+/****************************************************************************
+report a possible attack via the password buffer overflow bug
+****************************************************************************/
+static void overflow_attack(int len)
+{
+ DEBUG(0,("ERROR: Invalid password length %d\n", len));
+ DEBUG(0,("you're machine may be under attack by a user exploiting an old bug\n"));
+ DEBUG(0,("Attack was from IP=%s\n", client_addr()));
+ exit_server("possible attack");
+}
+
+
/****************************************************************************
reply to an special message
****************************************************************************/
@@ -69,22 +81,22 @@ int reply_special(char *inbuf,char *outbuf)
case 0x81: /* session request */
CVAL(outbuf,0) = 0x82;
CVAL(outbuf,3) = 0;
- if (name_len(inbuf+4) > 50) {
- DEBUG(0,("Invalid name length in session request\n"));
- return(0);
- }
+ if (name_len(inbuf+4) > 50 || name_len(inbuf+4 + name_len(inbuf + 4)) > 50) {
+ DEBUG(0,("Invalid name length in session request\n"));
+ return(0);
+ }
name_extract(inbuf,4,name1);
name_extract(inbuf,4 + name_len(inbuf + 4),name2);
DEBUG(2,("netbios connect: name1=%s name2=%s\n",
name1,name2));
- strcpy(remote_machine,name2);
+ fstrcpy(remote_machine,name2);
trim_string(remote_machine," "," ");
p = strchr(remote_machine,' ');
strlower(remote_machine);
if (p) *p = 0;
- strcpy(local_machine,name1);
+ fstrcpy(local_machine,name1);
trim_string(local_machine," "," ");
p = strchr(local_machine,' ');
strlower(local_machine);
@@ -160,25 +172,25 @@ static void parse_connect(char *p,char *service,char *user,
p2 = strrchr(p,'\\');
if (p2 == NULL)
- strcpy(service,p);
+ fstrcpy(service,p);
else
- strcpy(service,p2+1);
+ fstrcpy(service,p2+1);
p += strlen(p) + 2;
- strcpy(password,p);
+ fstrcpy(password,p);
*pwlen = strlen(password);
p += strlen(p) + 2;
- strcpy(dev,p);
+ fstrcpy(dev,p);
*user = 0;
p = strchr(service,'%');
if (p != NULL)
{
*p = 0;
- strcpy(user,p+1);
+ fstrcpy(user,p+1);
}
}
@@ -238,6 +250,10 @@ int reply_tcon_and_X(char *inbuf,char *outbuf,int length,int bufsize)
/* we might have to close an old one */
if ((SVAL(inbuf,smb_vwv2) & 0x1) != 0)
close_cnum(SVAL(inbuf,smb_tid),vuid);
+
+ if (passlen > MAX_PASSWORD_LENGTH) {
+ overflow_attack(passlen);
+ }
{
char *path;
@@ -252,18 +268,17 @@ int reply_tcon_and_X(char *inbuf,char *outbuf,int length,int bufsize)
passlen = strlen(password);
}
- DEBUG(4,("parsing net-path %s, passlen=%d\n",path,passlen));
- strcpy(service,path+2);
+ fstrcpy(service,path+2);
p = strchr(service,'\\');
if (!p)
return(ERROR(ERRSRV,ERRinvnetname));
*p = 0;
- strcpy(service,p+1);
+ fstrcpy(service,p+1);
p = strchr(service,'%');
if (p)
{
*p++ = 0;
- strcpy(user,p);
+ fstrcpy(user,p);
}
StrnCpy(devicename,path + strlen(path) + 1,6);
DEBUG(4,("Got device type %s\n",devicename));
@@ -372,11 +387,15 @@ int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize)
if (Protocol < PROTOCOL_NT1) {
smb_apasslen = SVAL(inbuf,smb_vwv7);
+ if (smb_apasslen > MAX_PASSWORD_LENGTH)
+ overflow_attack(smb_apasslen);
+
memcpy(smb_apasswd,smb_buf(inbuf),smb_apasslen);
- StrnCpy(user,smb_buf(inbuf)+smb_apasslen,sizeof(user)-1);
+ pstrcpy(user,smb_buf(inbuf)+smb_apasslen);
- if (lp_security() != SEC_SERVER && !doencrypt)
- smb_apasslen = strlen(smb_apasswd);
+ if (lp_security() != SEC_SERVER && !doencrypt) {
+ smb_apasslen = strlen(smb_apasswd);
+ }
} else {
uint16 passlen1 = SVAL(inbuf,smb_vwv7);
uint16 passlen2 = SVAL(inbuf,smb_vwv8);
@@ -401,6 +420,13 @@ int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize)
if (passlen1 != 24 && passlen2 != 24)
doencrypt = False;
+ if (passlen1 > MAX_PASSWORD_LENGTH) {
+ overflow_attack(passlen1);
+ }
+
+ passlen1 = MIN(passlen1, MAX_PASSWORD_LENGTH);
+ passlen2 = MIN(passlen2, MAX_PASSWORD_LENGTH);
+
if(doencrypt) {
/* Save the lanman2 password and the NT md4 password. */
smb_apasslen = passlen1;
@@ -438,7 +464,7 @@ int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize)
}
p += passlen1 + passlen2;
- strcpy(user,p); p = skip_string(p,1);
+ fstrcpy(user,p); p = skip_string(p,1);
DEBUG(3,("Domain=[%s] NativeOS=[%s] NativeLanMan=[%s]\n",
p,skip_string(p,1),skip_string(p,2)));
}
@@ -591,7 +617,7 @@ int reply_chkpth(char *inbuf,char *outbuf)
cnum = SVAL(inbuf,smb_tid);
- strcpy(name,smb_buf(inbuf) + 1);
+ pstrcpy(name,smb_buf(inbuf) + 1);
unix_convert(name,cnum,0,&bad_path);
mode = SVAL(inbuf,smb_vwv0);
@@ -639,7 +665,7 @@ int reply_getatr(char *inbuf,char *outbuf)
cnum = SVAL(inbuf,smb_tid);
- strcpy(fname,smb_buf(inbuf) + 1);
+ pstrcpy(fname,smb_buf(inbuf) + 1);
unix_convert(fname,cnum,0,&bad_path);
/* dos smetimes asks for a stat of "" - it returns a "hidden directory"
@@ -714,7 +740,7 @@ int reply_setatr(char *inbuf,char *outbuf)
cnum = SVAL(inbuf,smb_tid);
- strcpy(fname,smb_buf(inbuf) + 1);
+ pstrcpy(fname,smb_buf(inbuf) + 1);
unix_convert(fname,cnum,0,&bad_path);
mode = SVAL(inbuf,smb_vwv0);
@@ -825,8 +851,8 @@ int reply_search(char *inbuf,char *outbuf)
{
pstring dir2;
- strcpy(directory,smb_buf(inbuf)+1);
- strcpy(dir2,smb_buf(inbuf)+1);
+ pstrcpy(directory,smb_buf(inbuf)+1);
+ pstrcpy(dir2,smb_buf(inbuf)+1);
unix_convert(directory,cnum,0,&bad_path);
unix_format(dir2);
@@ -842,7 +868,7 @@ int reply_search(char *inbuf,char *outbuf)
else
{
*p = 0;
- strcpy(mask,p+1);
+ pstrcpy(mask,p+1);
}
p = strrchr(directory,'/');
@@ -876,7 +902,7 @@ int reply_search(char *inbuf,char *outbuf)
if ((p = strrchr(mask,' ')))
{
fstring ext;
- strcpy(ext,p+1);
+ fstrcpy(ext,p+1);
*p = 0;
trim_string(mask,NULL," ");
strcat(mask,".");
@@ -898,7 +924,7 @@ int reply_search(char *inbuf,char *outbuf)
if (!strchr(mask,'.') && strlen(mask)>8)
{
fstring tmp;
- strcpy(tmp,&mask[8]);
+ fstrcpy(tmp,&mask[8]);
mask[8] = '.';
mask[9] = 0;
strcat(mask,tmp);
@@ -1078,7 +1104,7 @@ int reply_open(char *inbuf,char *outbuf)
share_mode = SVAL(inbuf,smb_vwv0);
- strcpy(fname,smb_buf(inbuf)+1);
+ pstrcpy(fname,smb_buf(inbuf)+1);
unix_convert(fname,cnum,0,&bad_path);
fnum = find_free_file();
@@ -1168,7 +1194,7 @@ int reply_open_and_X(char *inbuf,char *outbuf,int length,int bufsize)
/* XXXX we need to handle passed times, sattr and flags */
- strcpy(fname,smb_buf(inbuf));
+ pstrcpy(fname,smb_buf(inbuf));
unix_convert(fname,cnum,0,&bad_path);
fnum = find_free_file();
@@ -1281,7 +1307,7 @@ int reply_mknew(char *inbuf,char *outbuf)
cnum = SVAL(inbuf,smb_tid);
createmode = SVAL(inbuf,smb_vwv0);
- strcpy(fname,smb_buf(inbuf)+1);
+ pstrcpy(fname,smb_buf(inbuf)+1);
unix_convert(fname,cnum,0,&bad_path);
if (createmode & aVOLID)
@@ -1359,7 +1385,8 @@ int reply_ctemp(char *inbuf,char *outbuf)
cnum = SVAL(inbuf,smb_tid);
createmode = SVAL(inbuf,smb_vwv0);
- sprintf(fname,"%s/TMXXXXXX",smb_buf(inbuf)+1);
+ pstrcpy(fname,smb_buf(inbuf)+1);
+ strcat(fname,"/TMXXXXXX");
unix_convert(fname,cnum,0,&bad_path);
unixmode = unix_mode(cnum,createmode);
@@ -1455,7 +1482,7 @@ int reply_unlink(char *inbuf,char *outbuf)
cnum = SVAL(inbuf,smb_tid);
dirtype = SVAL(inbuf,smb_vwv0);
- strcpy(name,smb_buf(inbuf) + 1);
+ pstrcpy(name,smb_buf(inbuf) + 1);
DEBUG(3,("reply_unlink : %s\n",name));
@@ -1503,7 +1530,7 @@ int reply_unlink(char *inbuf,char *outbuf)
while ((dname = ReadDirName(dirptr)))
{
pstring fname;
- strcpy(fname,dname);
+ pstrcpy(fname,dname);
if(!mask_match(fname, mask, case_sensitive, False)) continue;
@@ -2381,7 +2408,7 @@ int reply_printopen(char *inbuf,char *outbuf)
{
pstring s;
char *p;
- StrnCpy(s,smb_buf(inbuf)+1,sizeof(pstring)-1);
+ pstrcpy(s,smb_buf(inbuf)+1);
p = s;
while (*p)
{
@@ -2583,7 +2610,7 @@ int reply_mkdir(char *inbuf,char *outbuf)
int outsize,ret= -1;
BOOL bad_path = False;
- strcpy(directory,smb_buf(inbuf) + 1);
+ pstrcpy(directory,smb_buf(inbuf) + 1);
cnum = SVAL(inbuf,smb_tid);
unix_convert(directory,cnum,0,&bad_path);
@@ -2620,7 +2647,7 @@ int reply_rmdir(char *inbuf,char *outbuf)
BOOL bad_path = False;
cnum = SVAL(inbuf,smb_tid);
- strcpy(directory,smb_buf(inbuf) + 1);
+ pstrcpy(directory,smb_buf(inbuf) + 1);
unix_convert(directory,cnum,0,&bad_path);
if (check_name(directory,cnum))
@@ -2668,7 +2695,7 @@ int reply_rmdir(char *inbuf,char *outbuf)
errno = ENOMEM;
break;
}
- strcpy(fullname, directory);
+ pstrcpy(fullname, directory);
strcat(fullname, "/");
strcat(fullname, dname);
@@ -2730,21 +2757,21 @@ static BOOL resolve_wildcards(char *name1,char *name2)
if (!name1 || !name2) return(False);
- strcpy(root1,name1);
- strcpy(root2,name2);
+ fstrcpy(root1,name1);
+ fstrcpy(root2,name2);
p = strrchr(root1,'.');
if (p) {
*p = 0;
- strcpy(ext1,p+1);
+ fstrcpy(ext1,p+1);
} else {
- strcpy(ext1,"");
+ fstrcpy(ext1,"");
}
p = strrchr(root2,'.');
if (p) {
*p = 0;
- strcpy(ext2,p+1);
+ fstrcpy(ext2,p+1);
} else {
- strcpy(ext2,"");
+ fstrcpy(ext2,"");
}
p = root1;
@@ -2818,8 +2845,8 @@ int reply_mv(char *inbuf,char *outbuf)
cnum = SVAL(inbuf,smb_tid);
- strcpy(name,smb_buf(inbuf) + 1);
- strcpy(newname,smb_buf(inbuf) + 3 + strlen(name));
+ pstrcpy(name,smb_buf(inbuf) + 1);
+ pstrcpy(newname,smb_buf(inbuf) + 3 + strlen(name));
DEBUG(3,("reply_mv : %s -> %s\n",name,newname));
@@ -2933,14 +2960,14 @@ int reply_mv(char *inbuf,char *outbuf)
while ((dname = ReadDirName(dirptr)))
{
pstring fname;
- strcpy(fname,dname);
+ pstrcpy(fname,dname);
if(!mask_match(fname, mask, case_sensitive, False)) continue;
error = ERRnoaccess;
sprintf(fname,"%s/%s",directory,dname);
if (!can_rename(fname,cnum)) continue;
- strcpy(destname,newname);
+ pstrcpy(destname,newname);
if (!resolve_wildcards(fname,destname)) continue;
@@ -2986,7 +3013,7 @@ static BOOL copy_file(char *src,char *dest1,int cnum,int ofun,
int fnum1,fnum2;
pstring dest;
- strcpy(dest,dest1);
+ pstrcpy(dest,dest1);
if (target_is_directory) {
char *p = strrchr(src,'/');
if (p)
@@ -3063,8 +3090,8 @@ int reply_copy(char *inbuf,char *outbuf)
cnum = SVAL(inbuf,smb_tid);
- strcpy(name,smb_buf(inbuf));
- strcpy(newname,smb_buf(inbuf) + 1 + strlen(name));
+ pstrcpy(name,smb_buf(inbuf));
+ pstrcpy(newname,smb_buf(inbuf) + 1 + strlen(name));
DEBUG(3,("reply_copy : %s -> %s\n",name,newname));
@@ -3133,7 +3160,7 @@ int reply_copy(char *inbuf,char *outbuf)
while ((dname = ReadDirName(dirptr)))
{
pstring fname;
- strcpy(fname,dname);
+ pstrcpy(fname,dname);
if(!mask_match(fname, mask, case_sensitive, False)) continue;
@@ -3187,7 +3214,7 @@ int reply_setdir(char *inbuf,char *outbuf)
if (!CAN_SETDIR(snum))
return(ERROR(ERRDOS,ERRnoaccess));
- strcpy(newdir,smb_buf(inbuf) + 1);
+ pstrcpy(newdir,smb_buf(inbuf) + 1);
strlower(newdir);
if (strlen(newdir) == 0)
diff --git a/source/smbd/server.c b/source/smbd/server.c
index d4407269f0b..2bc0e023158 100644
--- a/source/smbd/server.c
+++ b/source/smbd/server.c
@@ -393,7 +393,7 @@ static BOOL scan_directory(char *path, char *name,int cnum,BOOL docache)
(strequal(dname,".") || strequal(dname,"..")))
continue;
- strcpy(name2,dname);
+ pstrcpy(name2,dname);
if (!name_map_mangle(name2,False,SNUM(cnum))) continue;
if ((mangled && mangled_equal(name,name2))
@@ -539,7 +539,7 @@ BOOL unix_convert(char *name,int cnum,pstring saved_last_component, BOOL *bad_pa
/* remember the rest of the pathname so it can be restored
later */
- if (end) strcpy(rest,end+1);
+ if (end) pstrcpy(rest,end+1);
/* try to find this part of the path in the directory */
if (strchr(start,'?') || strchr(start,'*') ||
@@ -1051,7 +1051,7 @@ static void open_file(int fnum,int cnum,char *fname1,int flags,int mode, struct
Files[fnum].fd_ptr = 0;
errno = EPERM;
- strcpy(fname,fname1);
+ pstrcpy(fname,fname1);
/* check permissions */
if ((flags != O_RDONLY) && !CAN_WRITE(cnum) && !Connections[cnum].printer)
@@ -1180,7 +1180,7 @@ static void open_file(int fnum,int cnum,char *fname1,int flags,int mode, struct
pstring dname;
int dum1,dum2,dum3;
char *p;
- strcpy(dname,fname);
+ pstrcpy(dname,fname);
p = strrchr(dname,'/');
if (p) *p = 0;
if (sys_disk_free(dname,&dum1,&dum2,&dum3) <
@@ -1315,10 +1315,10 @@ static void check_magic(int fnum,int cnum)
int ret;
pstring magic_output;
pstring fname;
- strcpy(fname,Files[fnum].name);
+ pstrcpy(fname,Files[fnum].name);
if (*lp_magicoutput(SNUM(cnum)))
- strcpy(magic_output,lp_magicoutput(SNUM(cnum)));
+ pstrcpy(magic_output,lp_magicoutput(SNUM(cnum)));
else
sprintf(magic_output,"%s.out",fname);
@@ -2280,10 +2280,10 @@ BOOL reload_services(BOOL test)
if (lp_loaded())
{
pstring fname;
- strcpy(fname,lp_configfile());
+ pstrcpy(fname,lp_configfile());
if (file_exist(fname,NULL) && !strcsequal(fname,servicesf))
{
- strcpy(servicesf,fname);
+ pstrcpy(servicesf,fname);
test = False;
}
}
@@ -2576,13 +2576,13 @@ int make_connection(char *service,char *user,char *password, int pwlen, char *de
{
struct passwd *pass2;
fstring fuser;
- strcpy(fuser,lp_force_user(snum));
+ fstrcpy(fuser,lp_force_user(snum));
pass2 = (struct passwd *)Get_Pwnam(fuser,True);
if (pass2)
{
pcon->uid = pass2->pw_uid;
string_set(&pcon->user,fuser);
- strcpy(user,fuser);
+ fstrcpy(user,fuser);
pcon->force_user = True;
DEBUG(3,("Forced user %s\n",fuser));
}
@@ -2592,7 +2592,7 @@ int make_connection(char *service,char *user,char *password, int pwlen, char *de
{
pstring s;
- strcpy(s,lp_pathname(snum));
+ pstrcpy(s,lp_pathname(snum));
standard_sub(cnum,s);
string_set(&pcon->connectpath,s);
DEBUG(3,("Connect path is %s\n",s));
@@ -2628,7 +2628,7 @@ int make_connection(char *service,char *user,char *password, int pwlen, char *de
if (*lp_rootpreexec(SNUM(cnum)))
{
pstring cmd;
- strcpy(cmd,lp_rootpreexec(SNUM(cnum)));
+ pstrcpy(cmd,lp_rootpreexec(SNUM(cnum)));
standard_sub(cnum,cmd);
DEBUG(5,("cmd=%s\n",cmd));
smbrun(cmd,NULL,False);
@@ -2668,7 +2668,7 @@ int make_connection(char *service,char *user,char *password, int pwlen, char *de
/* resolve any soft links early */
{
pstring s;
- strcpy(s,pcon->connectpath);
+ pstrcpy(s,pcon->connectpath);
GetWd(s);
string_set(&pcon->connectpath,s);
ChDir(pcon->connectpath);
@@ -2682,7 +2682,7 @@ int make_connection(char *service,char *user,char *password, int pwlen, char *de
if (*lp_preexec(SNUM(cnum)))
{
pstring cmd;
- strcpy(cmd,lp_preexec(SNUM(cnum)));
+ pstrcpy(cmd,lp_preexec(SNUM(cnum)));
standard_sub(cnum,cmd);
smbrun(cmd,NULL,False);
}
@@ -3153,7 +3153,7 @@ static int reply_negprot(char *inbuf,char *outbuf)
SSVAL(outbuf,smb_vwv0,choice);
if(choice != -1) {
extern fstring remote_proto;
- strcpy(remote_proto,supported_protocols[protocol].short_name);
+ fstrcpy(remote_proto,supported_protocols[protocol].short_name);
reload_services(True);
outsize = supported_protocols[protocol].proto_reply_fn(outbuf);
DEBUG(3,("Selected protocol %s\n",supported_protocols[protocol].proto_name));
@@ -3272,7 +3272,7 @@ BOOL yield_connection(int cnum,char *name,int max_connections)
bzero(&crec,sizeof(crec));
- strcpy(fname,lp_lockdir());
+ pstrcpy(fname,lp_lockdir());
standard_sub(cnum,fname);
trim_string(fname,"","/");
@@ -3344,7 +3344,7 @@ BOOL claim_connection(int cnum,char *name,int max_connections,BOOL Clear)
DEBUG(5,("trying claim %s %s %d\n",lp_lockdir(),name,max_connections));
- strcpy(fname,lp_lockdir());
+ pstrcpy(fname,lp_lockdir());
standard_sub(cnum,fname);
trim_string(fname,"","/");
@@ -3440,7 +3440,7 @@ static BOOL dump_core(void)
{
char *p;
pstring dname;
- strcpy(dname,debugf);
+ pstrcpy(dname,debugf);
if ((p=strrchr(dname,'/'))) *p=0;
strcat(dname,"/corefiles");
mkdir(dname,0700);
diff --git a/source/smbd/trans2.c b/source/smbd/trans2.c
index 19c1158658c..ecc8f5dbec7 100644
--- a/source/smbd/trans2.c
+++ b/source/smbd/trans2.c
@@ -306,10 +306,10 @@ static int get_lanman2_dir_entry(int cnum,char *path_mask,int dirtype,int info_l
if(p[1] == '\0')
strcpy(mask,"*.*");
else
- strcpy(mask, p+1);
+ pstrcpy(mask, p+1);
}
else
- strcpy(mask, path_mask);
+ pstrcpy(mask, path_mask);
while (!found)
{
@@ -327,7 +327,7 @@ static int get_lanman2_dir_entry(int cnum,char *path_mask,int dirtype,int info_l
matched = False;
- strcpy(fname,dname);
+ pstrcpy(fname,dname);
if(mask_match(fname, mask, case_sensitive, True))
{
@@ -338,7 +338,7 @@ static int get_lanman2_dir_entry(int cnum,char *path_mask,int dirtype,int info_l
if (isrootdir && isdots)
continue;
- strcpy(pathreal,Connections[cnum].dirpath);
+ pstrcpy(pathreal,Connections[cnum].dirpath);
if(needslash)
strcat(pathreal,"/");
strcat(pathreal,dname);
@@ -595,7 +595,7 @@ static int call_trans2findfirst(char *inbuf, char *outbuf, int bufsize, int cnum
return(ERROR(ERRDOS,ERRunknownlevel));
}
- strcpy(directory, params + 12); /* Complete directory path with
+ pstrcpy(directory, params + 12); /* Complete directory path with
wildcard mask appended */
DEBUG(5,("path=%s\n",directory));
@@ -1057,7 +1057,7 @@ static int call_trans2qfilepathinfo(char *inbuf, char *outbuf, int length,
/* qpathinfo */
info_level = SVAL(params,0);
fname = &fname1[0];
- strcpy(fname,¶ms[6]);
+ pstrcpy(fname,¶ms[6]);
unix_convert(fname,cnum,0,&bad_path);
if (!check_name(fname,cnum) || sys_stat(fname,&sbuf)) {
DEBUG(3,("fileinfo of %s failed (%s)\n",fname,strerror(errno)));
@@ -1163,7 +1163,7 @@ static int call_trans2qfilepathinfo(char *inbuf, char *outbuf, int length,
case SMB_QUERY_FILE_ALT_NAME_INFO:
data_size = 4 + l;
SIVAL(pdata,0,l);
- strcpy(pdata+4,fname);
+ pstrcpy(pdata+4,fname);
break;
case SMB_QUERY_FILE_ALLOCATION_INFO:
case SMB_QUERY_FILE_END_OF_FILEINFO:
@@ -1197,7 +1197,7 @@ static int call_trans2qfilepathinfo(char *inbuf, char *outbuf, int length,
pdata += 4;
pdata += 4; /* alignment */
SIVAL(pdata,0,l);
- strcpy(pdata+4,fname);
+ pstrcpy(pdata+4,fname);
pdata += 4 + l;
data_size = PTR_DIFF(pdata,(*ppdata));
break;
@@ -1208,7 +1208,7 @@ static int call_trans2qfilepathinfo(char *inbuf, char *outbuf, int length,
SIVAL(pdata,4,size);
SIVAL(pdata,12,size);
SIVAL(pdata,20,l);
- strcpy(pdata+24,fname);
+ pstrcpy(pdata+24,fname);
break;
default:
return(ERROR(ERRDOS,ERRunknownlevel));
@@ -1260,7 +1260,7 @@ static int call_trans2setfilepathinfo(char *inbuf, char *outbuf, int length,
/* set path info */
info_level = SVAL(params,0);
fname = fname1;
- strcpy(fname,¶ms[6]);
+ pstrcpy(fname,¶ms[6]);
unix_convert(fname,cnum,0,&bad_path);
if(!check_name(fname, cnum))
{
@@ -1435,7 +1435,7 @@ static int call_trans2mkdir(char *inbuf, char *outbuf, int length, int bufsize,
if (!CAN_WRITE(cnum))
return(ERROR(ERRSRV,ERRaccess));
- strcpy(directory, ¶ms[4]);
+ pstrcpy(directory, ¶ms[4]);
DEBUG(3,("call_trans2mkdir : name = %s\n", directory));
@@ -1637,6 +1637,9 @@ int reply_trans2(char *inbuf,char *outbuf,int length,int bufsize)
num_params = num_params_sofar = SVAL(inbuf,smb_pscnt);
num_data = num_data_sofar = SVAL(inbuf, smb_dscnt);
+ if (num_params > total_params || num_data > total_data)
+ exit_server("invalid params in reply_trans2");
+
memcpy( params, smb_base(inbuf) + SVAL(inbuf, smb_psoff), num_params);
memcpy( data, smb_base(inbuf) + SVAL(inbuf, smb_dsoff), num_data);
@@ -1664,6 +1667,9 @@ int reply_trans2(char *inbuf,char *outbuf,int length,int bufsize)
total_data = SVAL(inbuf, smb_tdscnt);
num_params_sofar += (num_params = SVAL(inbuf,smb_spscnt));
num_data_sofar += ( num_data = SVAL(inbuf, smb_sdscnt));
+ if (num_params_sofar > total_params || num_data_sofar > total_data)
+ exit_server("data overflow in trans2");
+
memcpy( ¶ms[ SVAL(inbuf, smb_spsdisp)],
smb_base(inbuf) + SVAL(inbuf, smb_spsoff), num_params);
memcpy( &data[SVAL(inbuf, smb_sdsdisp)],
diff --git a/source/smbd/vt_mode.c b/source/smbd/vt_mode.c
index 0a4d50c217f..07558274a52 100644
--- a/source/smbd/vt_mode.c
+++ b/source/smbd/vt_mode.c
@@ -81,7 +81,7 @@ int VT_Start_utmp(void)
setutent();
- strcpy(u.ut_line, VT_Line);
+ fstrcpy(u.ut_line, VT_Line);
if((v = getutline(&u)) == NULL) {
if(strncmp(VT_Line, "tty", 3) == 0)
@@ -91,12 +91,12 @@ int VT_Start_utmp(void)
else
tt = VT_Line;
- strcpy(u.ut_id, tt);
+ fstrcpy(u.ut_id, tt);
u.ut_time = time((time_t*)0);
}
- strcpy(u.ut_user, "LOGIN");
- strcpy(u.ut_line, VT_Line);
+ fstrcpy(u.ut_user, "LOGIN");
+ fstrcpy(u.ut_line, VT_Line);
u.ut_pid = getpid();
u.ut_type = LOGIN_PROCESS;
pututline(&u);
@@ -118,10 +118,10 @@ int VT_Stop_utmp(void)
if(VT_Line != NULL) {
setutent();
- strcpy(u.ut_line, VT_Line);
+ fstrcpy(u.ut_line, VT_Line);
if((v = getutline(&u)) != NULL) {
- strcpy(v->ut_user, "");
+ fstrcpy(v->ut_user, "");
v->ut_type = DEAD_PROCESS;
v->ut_time = time((time_t*)0);
pututline(v);
diff --git a/source/utils/nmblookup.c b/source/utils/nmblookup.c
index 25c94dcd6a0..aebbc4292ca 100644
--- a/source/utils/nmblookup.c
+++ b/source/utils/nmblookup.c
@@ -122,7 +122,7 @@ int main(int argc,char *argv[])
got_bcast = True;
break;
case 'i':
- strcpy(scope,optarg);
+ fstrcpy(scope,optarg);
strupper(scope);
break;
case 'M':
@@ -135,7 +135,7 @@ int main(int argc,char *argv[])
DEBUGLEVEL = atoi(optarg);
break;
case 's':
- strcpy(servicesf, optarg);
+ pstrcpy(servicesf, optarg);
break;
case 'h':
usage();
@@ -172,7 +172,7 @@ int main(int argc,char *argv[])
char *p;
struct in_addr ip;
- strcpy(lookup,argv[i]);
+ fstrcpy(lookup,argv[i]);
if (find_master) {
if (*lookup == '-') {
--
cgit
From 9d23bcbe5fac31017f5392478994df2d6a7e0d91 Mon Sep 17 00:00:00 2001
From: Samba Release Account
Date: Fri, 26 Sep 1997 12:47:59 +0000
Subject: preparing for release of 1.9.17p2
---
source/include/version.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source/include/version.h b/source/include/version.h
index afd20f5799d..76ccca122c6 100644
--- a/source/include/version.h
+++ b/source/include/version.h
@@ -1 +1 @@
-#define VERSION "1.9.17p1"
+#define VERSION "1.9.17p2"
--
cgit
From 9f8164d73583c32908ec3b9a6ae6630e78723553 Mon Sep 17 00:00:00 2001
From: Andrew Tridgell
Date: Fri, 26 Sep 1997 13:09:36 +0000
Subject: add info about p2 release
---
WHATSNEW.txt | 42 ++++++++++++++++++------------------------
1 file changed, 18 insertions(+), 24 deletions(-)
diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index 500a4726bf2..fa3600d6c35 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -1,37 +1,31 @@
- WHATS NEW IN 1.9.17p1 - September 5 1997
- ========================================
+ WHATS NEW IN 1.9.17p2 - September 26th 1997
+ ===========================================
-New stable patch release: Samba - version 1.9.17p1.
----------------------------------------------------
+Security fix release: Samba - version 1.9.17p2.
+----------------------------------------------
-This is a patch release which superceedes the
-last stable release of Samba, release 1.9.17.
-This release fixes the few bugs that users reported
-in the previous stable release (1.9.17).
+This new stable release fixes a very important security hole in all
+versions of Samba.
-These bugfixes are :
+The security hole allows a remote user to obtain root access on the
+Samba server. A program which exploits this bug has been posted to the
+internet.
-Fix for DOS and Windows 95 clients having trouble
-delting files on a Samba share in a DOS command line
-environment.
+The security hole is only known to affect Samba servers running on
+Intel based hardware, and has only been demonstrated for Intel
+Linux. It is likley that exploits for other architectures would be
+very difficult but the possibility cannot be excluded completely.
-Fixes to set the 'flag' bits correctly when talking to a
-non-Samba WINS server.
+This patch fixes the security hole for all platforms.
-Fix for NT clients being dropped when using security=server.
+This patch also adds a routine which will log a message when a user
+attempts to take advantage of the security hole.
-Fixes to the printer queue reporting code.
-
-Fix for the name map mangle bug (mangling .html -> .htm was
-not working).
-
-If you are not affected by any of these problems then there
-is no need to upgrade.
-
-The release notes from the previous stable release follow.
+A number of other minor bugs have also been fixed in this release.
The Samba Team.
+
-------------Previous release notes-------------------------
New stable release of Samba - 1.9.17
--
cgit
From 4488171706e774eba415cced394551f40677089f Mon Sep 17 00:00:00 2001
From: Jeremy Allison
Date: Fri, 26 Sep 1997 19:40:59 +0000
Subject: Fixed you're -> your text that some pedant complained about :-).
Jeremy (jallison@whistle.com).
---
source/smbd/reply.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source/smbd/reply.c b/source/smbd/reply.c
index 4235e7725e9..6d7a3577c6c 100644
--- a/source/smbd/reply.c
+++ b/source/smbd/reply.c
@@ -54,7 +54,7 @@ report a possible attack via the password buffer overflow bug
static void overflow_attack(int len)
{
DEBUG(0,("ERROR: Invalid password length %d\n", len));
- DEBUG(0,("you're machine may be under attack by a user exploiting an old bug\n"));
+ DEBUG(0,("your machine may be under attack by a user exploiting an old bug\n"));
DEBUG(0,("Attack was from IP=%s\n", client_addr()));
exit_server("possible attack");
}
--
cgit
From 898302839f25c33a5bd2e47be950e7c486456589 Mon Sep 17 00:00:00 2001
From: Jeremy Allison
Date: Fri, 26 Sep 1997 21:43:44 +0000
Subject: Cause overflow attack to return an error code rather than terminate
smbd. Terminating smbd allows a denial of service attack for multi-user NT
servers. Jeremy (jallison@whistle.com)
---
source/smbd/reply.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/source/smbd/reply.c b/source/smbd/reply.c
index 6d7a3577c6c..d0beb285d73 100644
--- a/source/smbd/reply.c
+++ b/source/smbd/reply.c
@@ -56,7 +56,10 @@ static void overflow_attack(int len)
DEBUG(0,("ERROR: Invalid password length %d\n", len));
DEBUG(0,("your machine may be under attack by a user exploiting an old bug\n"));
DEBUG(0,("Attack was from IP=%s\n", client_addr()));
+/* Don't exit server here - it allows a possible denial of service attack. */
+#if 0
exit_server("possible attack");
+#endif
}
@@ -253,6 +256,7 @@ int reply_tcon_and_X(char *inbuf,char *outbuf,int length,int bufsize)
if (passlen > MAX_PASSWORD_LENGTH) {
overflow_attack(passlen);
+ return(ERROR(ERRSRV,ERRbadpw));
}
{
@@ -388,7 +392,10 @@ int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize)
if (Protocol < PROTOCOL_NT1) {
smb_apasslen = SVAL(inbuf,smb_vwv7);
if (smb_apasslen > MAX_PASSWORD_LENGTH)
+ {
overflow_attack(smb_apasslen);
+ return(ERROR(ERRSRV,ERRbadpw));
+ }
memcpy(smb_apasswd,smb_buf(inbuf),smb_apasslen);
pstrcpy(user,smb_buf(inbuf)+smb_apasslen);
@@ -422,6 +429,7 @@ int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize)
if (passlen1 > MAX_PASSWORD_LENGTH) {
overflow_attack(passlen1);
+ return(ERROR(ERRSRV,ERRbadpw));
}
passlen1 = MIN(passlen1, MAX_PASSWORD_LENGTH);
--
cgit
From 078da3c0f89641cf9cfa0109cd20a1626e6fdb14 Mon Sep 17 00:00:00 2001
From: Jeremy Allison
Date: Sat, 27 Sep 1997 00:34:12 +0000
Subject: Put back changes to abort on overflow attack after conversation with
Andrew. Jeremy (jallison@whistle.com)
---
source/smbd/reply.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/source/smbd/reply.c b/source/smbd/reply.c
index d0beb285d73..f3a8ad22b8a 100644
--- a/source/smbd/reply.c
+++ b/source/smbd/reply.c
@@ -56,10 +56,7 @@ static void overflow_attack(int len)
DEBUG(0,("ERROR: Invalid password length %d\n", len));
DEBUG(0,("your machine may be under attack by a user exploiting an old bug\n"));
DEBUG(0,("Attack was from IP=%s\n", client_addr()));
-/* Don't exit server here - it allows a possible denial of service attack. */
-#if 0
exit_server("possible attack");
-#endif
}
@@ -256,7 +253,6 @@ int reply_tcon_and_X(char *inbuf,char *outbuf,int length,int bufsize)
if (passlen > MAX_PASSWORD_LENGTH) {
overflow_attack(passlen);
- return(ERROR(ERRSRV,ERRbadpw));
}
{
@@ -394,7 +390,6 @@ int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize)
if (smb_apasslen > MAX_PASSWORD_LENGTH)
{
overflow_attack(smb_apasslen);
- return(ERROR(ERRSRV,ERRbadpw));
}
memcpy(smb_apasswd,smb_buf(inbuf),smb_apasslen);
@@ -429,7 +424,6 @@ int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize)
if (passlen1 > MAX_PASSWORD_LENGTH) {
overflow_attack(passlen1);
- return(ERROR(ERRSRV,ERRbadpw));
}
passlen1 = MIN(passlen1, MAX_PASSWORD_LENGTH);
--
cgit
From f5bd28c611cc76d640661bd51edbb454601ed474 Mon Sep 17 00:00:00 2001
From: Jeremy Allison
Date: Mon, 29 Sep 1997 18:43:02 +0000
Subject: Fixed potential security bug with receive_smb passing in a pointer to
a pstring instead of a full sized buffer. Pointed out by : Matt Power
mhpower@mit.edu
Jeremy (jallison@whistle.com)
---
source/smbd/password.c | 45 +++++++++++++++++++++++++++++++--------------
1 file changed, 31 insertions(+), 14 deletions(-)
diff --git a/source/smbd/password.c b/source/smbd/password.c
index ed79d658a66..6d84a5ff61c 100644
--- a/source/smbd/password.c
+++ b/source/smbd/password.c
@@ -1510,13 +1510,14 @@ BOOL check_hosts_equiv(char *user)
int password_client = -1;
static fstring pserver;
+static char *secserver_inbuf = NULL;
/****************************************************************************
attempted support for server level security
****************************************************************************/
BOOL server_cryptkey(char *buf)
{
- pstring inbuf,outbuf;
+ pstring outbuf;
fstring pass_protocol;
extern fstring remote_machine;
char *p;
@@ -1526,6 +1527,14 @@ BOOL server_cryptkey(char *buf)
int port = SMB_PORT;
BOOL ret;
+ if(secserver_inbuf == NULL) {
+ secserver_inbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
+ if(secserver_inbuf == NULL) {
+ DEBUG(0,("server_cryptkey: malloc fail for input buffer.\n"));
+ return False;
+ }
+ }
+
if (password_client >= 0)
close(password_client);
password_client = -1;
@@ -1536,7 +1545,7 @@ BOOL server_cryptkey(char *buf)
strcpy(pass_protocol,"NT LM 0.12");
}
- bzero(inbuf,sizeof(inbuf));
+ bzero(secserver_inbuf,BUFFER_SIZE + SAFETY_MARGIN);
bzero(outbuf,sizeof(outbuf));
for (p=strtok(lp_passwordserver(),LIST_SEP); p ; p = strtok(NULL,LIST_SEP)) {
@@ -1602,8 +1611,8 @@ BOOL server_cryptkey(char *buf)
send_smb(password_client,outbuf);
- if (!receive_smb(password_client,inbuf,5000) ||
- CVAL(inbuf,0) != 0x82) {
+ if (!receive_smb(password_client,secserver_inbuf,5000) ||
+ CVAL(secserver_inbuf,0) != 0x82) {
DEBUG(1,("%s rejected the session\n",pserver));
close(password_client); password_client = -1;
return(False);
@@ -1624,21 +1633,21 @@ BOOL server_cryptkey(char *buf)
SSVAL(outbuf,smb_flg2,0x1);
send_smb(password_client,outbuf);
- ret = receive_smb(password_client,inbuf,5000);
+ ret = receive_smb(password_client,secserver_inbuf,5000);
- if (!ret || CVAL(inbuf,smb_rcls) || SVAL(inbuf,smb_vwv0)) {
+ if (!ret || CVAL(secserver_inbuf,smb_rcls) || SVAL(secserver_inbuf,smb_vwv0)) {
DEBUG(1,("%s rejected the protocol\n",pserver));
close(password_client); password_client= -1;
return(False);
}
- if (!(CVAL(inbuf,smb_vwv1) & 1)) {
+ if (!(CVAL(secserver_inbuf,smb_vwv1) & 1)) {
DEBUG(1,("%s isn't in user level security mode\n",pserver));
close(password_client); password_client= -1;
return(False);
}
- memcpy(buf,inbuf,smb_len(inbuf)+4);
+ memcpy(buf,secserver_inbuf,smb_len(secserver_inbuf)+4);
DEBUG(3,("password server OK\n"));
@@ -1650,15 +1659,23 @@ attempted support for server level security
****************************************************************************/
BOOL server_validate(char *buf)
{
- pstring inbuf,outbuf;
+ pstring outbuf;
BOOL ret;
+ if(secserver_inbuf == NULL) {
+ secserver_inbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
+ if(secserver_inbuf == NULL) {
+ DEBUG(0,("server_validate: malloc fail for input buffer.\n"));
+ return False;
+ }
+ }
+
if (password_client < 0) {
DEBUG(1,("%s not connected\n",pserver));
return(False);
}
- bzero(inbuf,sizeof(inbuf));
+ bzero(secserver_inbuf,BUFFER_SIZE + SAFETY_MARGIN);
memcpy(outbuf,buf,sizeof(outbuf));
/* send a session setup command */
@@ -1668,18 +1685,18 @@ BOOL server_validate(char *buf)
set_message(outbuf,smb_numwords(outbuf),smb_buflen(outbuf),False);
- SCVAL(inbuf,smb_rcls,1);
+ SCVAL(secserver_inbuf,smb_rcls,1);
send_smb(password_client,outbuf);
- ret = receive_smb(password_client,inbuf,5000);
+ ret = receive_smb(password_client,secserver_inbuf,5000);
- if (!ret || CVAL(inbuf,smb_rcls) != 0) {
+ if (!ret || CVAL(secserver_inbuf,smb_rcls) != 0) {
DEBUG(1,("password server %s rejected the password\n",pserver));
return(False);
}
/* if logged in as guest then reject */
- if ((SVAL(inbuf,smb_vwv2) & 1) != 0) {
+ if ((SVAL(secserver_inbuf,smb_vwv2) & 1) != 0) {
DEBUG(1,("password server %s gave us guest only\n",pserver));
return(False);
}
--
cgit
From 82ab76981f47431e88a2aae4782fbebe6e5d8182 Mon Sep 17 00:00:00 2001
From: Jeremy Allison
Date: Tue, 30 Sep 1997 17:13:32 +0000
Subject: Syncing up Support providers.
---
docs/textdocs/Support.txt | 56 ++++++++++++++++++++++++++++-------------------
1 file changed, 34 insertions(+), 22 deletions(-)
diff --git a/docs/textdocs/Support.txt b/docs/textdocs/Support.txt
index 0a5c41b1950..d482ac39123 100644
--- a/docs/textdocs/Support.txt
+++ b/docs/textdocs/Support.txt
@@ -33,7 +33,7 @@ Region Number of entries
ASIA 1
AUSTRALIA & NEW ZEALAND 18
CANADA 8
- EUROPE 34
+ EUROPE 35
MIDDLE EAST 1
AFRICA
@@ -1403,32 +1403,32 @@ http://www.alcove.fr Phone number: +33 01 40 85 80 06
------------------------------------------------------------------------------
BERLIN - GERMANY
-Name: innominate GbR
-Address: Soldiner Str. 96, 13359 Berlin; Bundesland: Berlin;
-Country: Germany
-Phone: +49 30 49308195, +49 177 2649655 (mobil)
-Fax: +49 30 49308196
-EMail: innominate@poboxes.com
+Name: innominate
+ Multifunktionale Serverloesungen und IT-Dienstleistungen
-Contact : Sascha Ottolski
+Address: Stresemannstraße 128, 10117 Berlin
+Country: Germany
+Phone: +49 30 202 90 477
+Fax: +49 30 202 90 249
+EMail: info@innominate.de
+Web: http://innominate.de
Type of support: vor Ort, Email, Fernzugriff ueber Internet/ISDN,
-Special
-expertise: Wir verfuegen ueber umfangreiche Erfahrung mit Samba, vor allem
- in Internet- und Intranetumgebungen. Neben Beratung, Dienstleistung
- und Schulung bieten wir auch individuell vorkonfigurierte
- Kommunikationsserver ("Lingo") auf der Basis von Linux an.
- Neben anderen Modulen (ISDN/Internet/Intranet/Email/Proxy
- u.a.) ist in Lingo ein Fileserver-Modul auf Samba-Basis inklusive
- einem mehrstufigen Firewallsystem enthalten.
- Außerdem verfuegt Lingo ueber eine grafische Administrations-
- oberflaeche, mit der z.B. das Hinzufuegen von neuen Benutzern
- von jedem Client per WWW-Browser moeglich ist.
+Wir verfuegen ueber umfangreiche Erfahrung mit Samba, vor allem
+in Intranetumgebungen. Neben Beratung, Dienstleistung
+und Schulung bieten wir auch individuell vorkonfigurierte
+Kommunikationsserver ("Lingo") auf der Basis von Linux an.
+Neben anderen Modulen (ISDN/Internet/Intranet/Email/Proxy
+u.a.) ist in Lingo ein Fileserver-Modul auf Samba-Basis inklusive
+einem mehrstufigen Firewallsystem enthalten.
+Außerdem verfuegt Lingo ueber eine grafische Administrations-
+oberflaeche, mit der z.B. das Hinzufuegen von neuen Benutzern
+von jedem Client per WWW-Browser moeglich ist.
-Sample prices: - Komplettpreise fuer Lingo nach Vereinbarung
- - 120 DM/Stunde fuer Dienstleistung
- - Schulung nach Vereinbarung
+Prices: Komplettpreise fuer Lingo nach Vereinbarung
+ 120 DM/Stunde fuer Dienstleistung
+ Schulung nach Vereinbarung
------------------------------------------------------------------------------
------------------------------------------------------------------------------
@@ -1547,6 +1547,18 @@ We are a Premium Partner of SCO and know and have used samba for four years.
Our engineers know a lot about the installation of SCO Unix.
------------------------------------------------------------------------------
+------------------------------------------------------------------------------
+GREECE
+
+Yiorgos Adamopoulos
+Electrical and Computer Engineer
+email: adamo@InterWorks.org
+
+I can provide Samba support for the following operating systems throughout the
+whole of Greece: Windows 3.11/95/NT, Ultrix, HP-UX, NetBSD, OpenBSD, SunOS,
+Solaris, Linux, Irix.
+------------------------------------------------------------------------------
+
------------------------------------------------------------------------------
SZEGED - HUNGARY
--
cgit
From 20bfde40b20f43cf8c6714ab9fb5a3fd17bc1575 Mon Sep 17 00:00:00 2001
From: Andrew Tridgell
Date: Sat, 4 Oct 1997 05:19:24 +0000
Subject: This is all the NT error codes less than 1000. I extracted them using
smbclient+netmon
If we want to start supporting NT error codes in Samba (which may be
forced upon us by buggy apps) then this is a good start.
---
source/include/nterr.h | 505 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 505 insertions(+)
create mode 100644 source/include/nterr.h
diff --git a/source/include/nterr.h b/source/include/nterr.h
new file mode 100644
index 00000000000..92f02612dbc
--- /dev/null
+++ b/source/include/nterr.h
@@ -0,0 +1,505 @@
+/* these are the NT error codes less than 1000. They are here for when
+ we start supporting NT error codes in Samba. They were extracted
+ using a loop in smbclient then printing a netmon sniff to a file */
+
+#define NT_STATUS_UNSUCCESSFUL (1)
+#define NT_STATUS_NOT_IMPLEMENTED (2)
+#define NT_STATUS_INVALID_INFO_CLASS (3)
+#define NT_STATUS_INFO_LENGTH_MISMATCH (4)
+#define NT_STATUS_ACCESS_VIOLATION (5)
+#define NT_STATUS_IN_PAGE_ERROR (6)
+#define NT_STATUS_PAGEFILE_QUOTA (7)
+#define NT_STATUS_INVALID_HANDLE (8)
+#define NT_STATUS_BAD_INITIAL_STACK (9)
+#define NT_STATUS_BAD_INITIAL_PC (10)
+#define NT_STATUS_INVALID_CID (11)
+#define NT_STATUS_TIMER_NOT_CANCELED (12)
+#define NT_STATUS_INVALID_PARAMETER (13)
+#define NT_STATUS_NO_SUCH_DEVICE (14)
+#define NT_STATUS_NO_SUCH_FILE (15)
+#define NT_STATUS_INVALID_DEVICE_REQUEST (16)
+#define NT_STATUS_END_OF_FILE (17)
+#define NT_STATUS_WRONG_VOLUME (18)
+#define NT_STATUS_NO_MEDIA_IN_DEVICE (19)
+#define NT_STATUS_UNRECOGNIZED_MEDIA (20)
+#define NT_STATUS_NONEXISTENT_SECTOR (21)
+#define NT_STATUS_MORE_PROCESSING_REQUIRED (22)
+#define NT_STATUS_NO_MEMORY (23)
+#define NT_STATUS_CONFLICTING_ADDRESSES (24)
+#define NT_STATUS_NOT_MAPPED_VIEW (25)
+#define NT_STATUS_UNABLE_TO_FREE_VM (26)
+#define NT_STATUS_UNABLE_TO_DELETE_SECTION (27)
+#define NT_STATUS_INVALID_SYSTEM_SERVICE (28)
+#define NT_STATUS_ILLEGAL_INSTRUCTION (29)
+#define NT_STATUS_INVALID_LOCK_SEQUENCE (30)
+#define NT_STATUS_INVALID_VIEW_SIZE (31)
+#define NT_STATUS_INVALID_FILE_FOR_SECTION (32)
+#define NT_STATUS_ALREADY_COMMITTED (33)
+#define NT_STATUS_ACCESS_DENIED (34)
+#define NT_STATUS_BUFFER_TOO_SMALL (35)
+#define NT_STATUS_OBJECT_TYPE_MISMATCH (36)
+#define NT_STATUS_NONCONTINUABLE_EXCEPTION (37)
+#define NT_STATUS_INVALID_DISPOSITION (38)
+#define NT_STATUS_UNWIND (39)
+#define NT_STATUS_BAD_STACK (40)
+#define NT_STATUS_INVALID_UNWIND_TARGET (41)
+#define NT_STATUS_NOT_LOCKED (42)
+#define NT_STATUS_PARITY_ERROR (43)
+#define NT_STATUS_UNABLE_TO_DECOMMIT_VM (44)
+#define NT_STATUS_NOT_COMMITTED (45)
+#define NT_STATUS_INVALID_PORT_ATTRIBUTES (46)
+#define NT_STATUS_PORT_MESSAGE_TOO_LONG (47)
+#define NT_STATUS_INVALID_PARAMETER_MIX (48)
+#define NT_STATUS_INVALID_QUOTA_LOWER (49)
+#define NT_STATUS_DISK_CORRUPT_ERROR (50)
+#define NT_STATUS_OBJECT_NAME_INVALID (51)
+#define NT_STATUS_OBJECT_NAME_NOT_FOUND (52)
+#define NT_STATUS_OBJECT_NAME_COLLISION (53)
+#define NT_STATUS_HANDLE_NOT_WAITABLE (54)
+#define NT_STATUS_PORT_DISCONNECTED (55)
+#define NT_STATUS_DEVICE_ALREADY_ATTACHED (56)
+#define NT_STATUS_OBJECT_PATH_INVALID (57)
+#define NT_STATUS_OBJECT_PATH_NOT_FOUND (58)
+#define NT_STATUS_OBJECT_PATH_SYNTAX_BAD (59)
+#define NT_STATUS_DATA_OVERRUN (60)
+#define NT_STATUS_DATA_LATE_ERROR (61)
+#define NT_STATUS_DATA_ERROR (62)
+#define NT_STATUS_CRC_ERROR (63)
+#define NT_STATUS_SECTION_TOO_BIG (64)
+#define NT_STATUS_PORT_CONNECTION_REFUSED (65)
+#define NT_STATUS_INVALID_PORT_HANDLE (66)
+#define NT_STATUS_SHARING_VIOLATION (67)
+#define NT_STATUS_QUOTA_EXCEEDED (68)
+#define NT_STATUS_INVALID_PAGE_PROTECTION (69)
+#define NT_STATUS_MUTANT_NOT_OWNED (70)
+#define NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED (71)
+#define NT_STATUS_PORT_ALREADY_SET (72)
+#define NT_STATUS_SECTION_NOT_IMAGE (73)
+#define NT_STATUS_SUSPEND_COUNT_EXCEEDED (74)
+#define NT_STATUS_THREAD_IS_TERMINATING (75)
+#define NT_STATUS_BAD_WORKING_SET_LIMIT (76)
+#define NT_STATUS_INCOMPATIBLE_FILE_MAP (77)
+#define NT_STATUS_SECTION_PROTECTION (78)
+#define NT_STATUS_EAS_NOT_SUPPORTED (79)
+#define NT_STATUS_EA_TOO_LARGE (80)
+#define NT_STATUS_NONEXISTENT_EA_ENTRY (81)
+#define NT_STATUS_NO_EAS_ON_FILE (82)
+#define NT_STATUS_EA_CORRUPT_ERROR (83)
+#define NT_STATUS_FILE_LOCK_CONFLICT (84)
+#define NT_STATUS_LOCK_NOT_GRANTED (85)
+#define NT_STATUS_DELETE_PENDING (86)
+#define NT_STATUS_CTL_FILE_NOT_SUPPORTED (87)
+#define NT_STATUS_UNKNOWN_REVISION (88)
+#define NT_STATUS_REVISION_MISMATCH (89)
+#define NT_STATUS_INVALID_OWNER (90)
+#define NT_STATUS_INVALID_PRIMARY_GROUP (91)
+#define NT_STATUS_NO_IMPERSONATION_TOKEN (92)
+#define NT_STATUS_CANT_DISABLE_MANDATORY (93)
+#define NT_STATUS_NO_LOGON_SERVERS (94)
+#define NT_STATUS_NO_SUCH_LOGON_SESSION (95)
+#define NT_STATUS_NO_SUCH_PRIVILEGE (96)
+#define NT_STATUS_PRIVILEGE_NOT_HELD (97)
+#define NT_STATUS_INVALID_ACCOUNT_NAME (98)
+#define NT_STATUS_USER_EXISTS (99)
+#define NT_STATUS_NO_SUCH_USER (100)
+#define NT_STATUS_GROUP_EXISTS (101)
+#define NT_STATUS_NO_SUCH_GROUP (102)
+#define NT_STATUS_MEMBER_IN_GROUP (103)
+#define NT_STATUS_MEMBER_NOT_IN_GROUP (104)
+#define NT_STATUS_LAST_ADMIN (105)
+#define NT_STATUS_WRONG_PASSWORD (106)
+#define NT_STATUS_ILL_FORMED_PASSWORD (107)
+#define NT_STATUS_PASSWORD_RESTRICTION (108)
+#define NT_STATUS_LOGON_FAILURE (109)
+#define NT_STATUS_ACCOUNT_RESTRICTION (110)
+#define NT_STATUS_INVALID_LOGON_HOURS (111)
+#define NT_STATUS_INVALID_WORKSTATION (112)
+#define NT_STATUS_PASSWORD_EXPIRED (113)
+#define NT_STATUS_ACCOUNT_DISABLED (114)
+#define NT_STATUS_NONE_MAPPED (115)
+#define NT_STATUS_TOO_MANY_LUIDS_REQUESTED (116)
+#define NT_STATUS_LUIDS_EXHAUSTED (117)
+#define NT_STATUS_INVALID_SUB_AUTHORITY (118)
+#define NT_STATUS_INVALID_ACL (119)
+#define NT_STATUS_INVALID_SID (120)
+#define NT_STATUS_INVALID_SECURITY_DESCR (121)
+#define NT_STATUS_PROCEDURE_NOT_FOUND (122)
+#define NT_STATUS_INVALID_IMAGE_FORMAT (123)
+#define NT_STATUS_NO_TOKEN (124)
+#define NT_STATUS_BAD_INHERITANCE_ACL (125)
+#define NT_STATUS_RANGE_NOT_LOCKED (126)
+#define NT_STATUS_DISK_FULL (127)
+#define NT_STATUS_SERVER_DISABLED (128)
+#define NT_STATUS_SERVER_NOT_DISABLED (129)
+#define NT_STATUS_TOO_MANY_GUIDS_REQUESTED (130)
+#define NT_STATUS_GUIDS_EXHAUSTED (131)
+#define NT_STATUS_INVALID_ID_AUTHORITY (132)
+#define NT_STATUS_AGENTS_EXHAUSTED (133)
+#define NT_STATUS_INVALID_VOLUME_LABEL (134)
+#define NT_STATUS_SECTION_NOT_EXTENDED (135)
+#define NT_STATUS_NOT_MAPPED_DATA (136)
+#define NT_STATUS_RESOURCE_DATA_NOT_FOUND (137)
+#define NT_STATUS_RESOURCE_TYPE_NOT_FOUND (138)
+#define NT_STATUS_RESOURCE_NAME_NOT_FOUND (139)
+#define NT_STATUS_ARRAY_BOUNDS_EXCEEDED (140)
+#define NT_STATUS_FLOAT_DENORMAL_OPERAND (141)
+#define NT_STATUS_FLOAT_DIVIDE_BY_ZERO (142)
+#define NT_STATUS_FLOAT_INEXACT_RESULT (143)
+#define NT_STATUS_FLOAT_INVALID_OPERATION (144)
+#define NT_STATUS_FLOAT_OVERFLOW (145)
+#define NT_STATUS_FLOAT_STACK_CHECK (146)
+#define NT_STATUS_FLOAT_UNDERFLOW (147)
+#define NT_STATUS_INTEGER_DIVIDE_BY_ZERO (148)
+#define NT_STATUS_INTEGER_OVERFLOW (149)
+#define NT_STATUS_PRIVILEGED_INSTRUCTION (150)
+#define NT_STATUS_TOO_MANY_PAGING_FILES (151)
+#define NT_STATUS_FILE_INVALID (152)
+#define NT_STATUS_ALLOTTED_SPACE_EXCEEDED (153)
+#define NT_STATUS_INSUFFICIENT_RESOURCES (154)
+#define NT_STATUS_DFS_EXIT_PATH_FOUND (155)
+#define NT_STATUS_DEVICE_DATA_ERROR (156)
+#define NT_STATUS_DEVICE_NOT_CONNECTED (157)
+#define NT_STATUS_DEVICE_POWER_FAILURE (158)
+#define NT_STATUS_FREE_VM_NOT_AT_BASE (159)
+#define NT_STATUS_MEMORY_NOT_ALLOCATED (160)
+#define NT_STATUS_WORKING_SET_QUOTA (161)
+#define NT_STATUS_MEDIA_WRITE_PROTECTED (162)
+#define NT_STATUS_DEVICE_NOT_READY (163)
+#define NT_STATUS_INVALID_GROUP_ATTRIBUTES (164)
+#define NT_STATUS_BAD_IMPERSONATION_LEVEL (165)
+#define NT_STATUS_CANT_OPEN_ANONYMOUS (166)
+#define NT_STATUS_BAD_VALIDATION_CLASS (167)
+#define NT_STATUS_BAD_TOKEN_TYPE (168)
+#define NT_STATUS_BAD_MASTER_BOOT_RECORD (169)
+#define NT_STATUS_INSTRUCTION_MISALIGNMENT (170)
+#define NT_STATUS_INSTANCE_NOT_AVAILABLE (171)
+#define NT_STATUS_PIPE_NOT_AVAILABLE (172)
+#define NT_STATUS_INVALID_PIPE_STATE (173)
+#define NT_STATUS_PIPE_BUSY (174)
+#define NT_STATUS_ILLEGAL_FUNCTION (175)
+#define NT_STATUS_PIPE_DISCONNECTED (176)
+#define NT_STATUS_PIPE_CLOSING (177)
+#define NT_STATUS_PIPE_CONNECTED (178)
+#define NT_STATUS_PIPE_LISTENING (179)
+#define NT_STATUS_INVALID_READ_MODE (180)
+#define NT_STATUS_IO_TIMEOUT (181)
+#define NT_STATUS_FILE_FORCED_CLOSED (182)
+#define NT_STATUS_PROFILING_NOT_STARTED (183)
+#define NT_STATUS_PROFILING_NOT_STOPPED (184)
+#define NT_STATUS_COULD_NOT_INTERPRET (185)
+#define NT_STATUS_FILE_IS_A_DIRECTORY (186)
+#define NT_STATUS_NOT_SUPPORTED (187)
+#define NT_STATUS_REMOTE_NOT_LISTENING (188)
+#define NT_STATUS_DUPLICATE_NAME (189)
+#define NT_STATUS_BAD_NETWORK_PATH (190)
+#define NT_STATUS_NETWORK_BUSY (191)
+#define NT_STATUS_DEVICE_DOES_NOT_EXIST (192)
+#define NT_STATUS_TOO_MANY_COMMANDS (193)
+#define NT_STATUS_ADAPTER_HARDWARE_ERROR (194)
+#define NT_STATUS_INVALID_NETWORK_RESPONSE (195)
+#define NT_STATUS_UNEXPECTED_NETWORK_ERROR (196)
+#define NT_STATUS_BAD_REMOTE_ADAPTER (197)
+#define NT_STATUS_PRINT_QUEUE_FULL (198)
+#define NT_STATUS_NO_SPOOL_SPACE (199)
+#define NT_STATUS_PRINT_CANCELLED (200)
+#define NT_STATUS_NETWORK_NAME_DELETED (201)
+#define NT_STATUS_NETWORK_ACCESS_DENIED (202)
+#define NT_STATUS_BAD_DEVICE_TYPE (203)
+#define NT_STATUS_BAD_NETWORK_NAME (204)
+#define NT_STATUS_TOO_MANY_NAMES (205)
+#define NT_STATUS_TOO_MANY_SESSIONS (206)
+#define NT_STATUS_SHARING_PAUSED (207)
+#define NT_STATUS_REQUEST_NOT_ACCEPTED (208)
+#define NT_STATUS_REDIRECTOR_PAUSED (209)
+#define NT_STATUS_NET_WRITE_FAULT (210)
+#define NT_STATUS_PROFILING_AT_LIMIT (211)
+#define NT_STATUS_NOT_SAME_DEVICE (212)
+#define NT_STATUS_FILE_RENAMED (213)
+#define NT_STATUS_VIRTUAL_CIRCUIT_CLOSED (214)
+#define NT_STATUS_NO_SECURITY_ON_OBJECT (215)
+#define NT_STATUS_CANT_WAIT (216)
+#define NT_STATUS_PIPE_EMPTY (217)
+#define NT_STATUS_CANT_ACCESS_DOMAIN_INFO (218)
+#define NT_STATUS_CANT_TERMINATE_SELF (219)
+#define NT_STATUS_INVALID_SERVER_STATE (220)
+#define NT_STATUS_INVALID_DOMAIN_STATE (221)
+#define NT_STATUS_INVALID_DOMAIN_ROLE (222)
+#define NT_STATUS_NO_SUCH_DOMAIN (223)
+#define NT_STATUS_DOMAIN_EXISTS (224)
+#define NT_STATUS_DOMAIN_LIMIT_EXCEEDED (225)
+#define NT_STATUS_OPLOCK_NOT_GRANTED (226)
+#define NT_STATUS_INVALID_OPLOCK_PROTOCOL (227)
+#define NT_STATUS_INTERNAL_DB_CORRUPTION (228)
+#define NT_STATUS_INTERNAL_ERROR (229)
+#define NT_STATUS_GENERIC_NOT_MAPPED (230)
+#define NT_STATUS_BAD_DESCRIPTOR_FORMAT (231)
+#define NT_STATUS_INVALID_USER_BUFFER (232)
+#define NT_STATUS_UNEXPECTED_IO_ERROR (233)
+#define NT_STATUS_UNEXPECTED_MM_CREATE_ERR (234)
+#define NT_STATUS_UNEXPECTED_MM_MAP_ERROR (235)
+#define NT_STATUS_UNEXPECTED_MM_EXTEND_ERR (236)
+#define NT_STATUS_NOT_LOGON_PROCESS (237)
+#define NT_STATUS_LOGON_SESSION_EXISTS (238)
+#define NT_STATUS_INVALID_PARAMETER_1 (239)
+#define NT_STATUS_INVALID_PARAMETER_2 (240)
+#define NT_STATUS_INVALID_PARAMETER_3 (241)
+#define NT_STATUS_INVALID_PARAMETER_4 (242)
+#define NT_STATUS_INVALID_PARAMETER_5 (243)
+#define NT_STATUS_INVALID_PARAMETER_6 (244)
+#define NT_STATUS_INVALID_PARAMETER_7 (245)
+#define NT_STATUS_INVALID_PARAMETER_8 (246)
+#define NT_STATUS_INVALID_PARAMETER_9 (247)
+#define NT_STATUS_INVALID_PARAMETER_10 (248)
+#define NT_STATUS_INVALID_PARAMETER_11 (249)
+#define NT_STATUS_INVALID_PARAMETER_12 (250)
+#define NT_STATUS_REDIRECTOR_NOT_STARTED (251)
+#define NT_STATUS_REDIRECTOR_STARTED (252)
+#define NT_STATUS_STACK_OVERFLOW (253)
+#define NT_STATUS_NO_SUCH_PACKAGE (254)
+#define NT_STATUS_BAD_FUNCTION_TABLE (255)
+#define NT_STATUS_DIRECTORY_NOT_EMPTY (257)
+#define NT_STATUS_FILE_CORRUPT_ERROR (258)
+#define NT_STATUS_NOT_A_DIRECTORY (259)
+#define NT_STATUS_BAD_LOGON_SESSION_STATE (260)
+#define NT_STATUS_LOGON_SESSION_COLLISION (261)
+#define NT_STATUS_NAME_TOO_LONG (262)
+#define NT_STATUS_FILES_OPEN (263)
+#define NT_STATUS_CONNECTION_IN_USE (264)
+#define NT_STATUS_MESSAGE_NOT_FOUND (265)
+#define NT_STATUS_PROCESS_IS_TERMINATING (266)
+#define NT_STATUS_INVALID_LOGON_TYPE (267)
+#define NT_STATUS_NO_GUID_TRANSLATION (268)
+#define NT_STATUS_CANNOT_IMPERSONATE (269)
+#define NT_STATUS_IMAGE_ALREADY_LOADED (270)
+#define NT_STATUS_ABIOS_NOT_PRESENT (271)
+#define NT_STATUS_ABIOS_LID_NOT_EXIST (272)
+#define NT_STATUS_ABIOS_LID_ALREADY_OWNED (273)
+#define NT_STATUS_ABIOS_NOT_LID_OWNER (274)
+#define NT_STATUS_ABIOS_INVALID_COMMAND (275)
+#define NT_STATUS_ABIOS_INVALID_LID (276)
+#define NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE (277)
+#define NT_STATUS_ABIOS_INVALID_SELECTOR (278)
+#define NT_STATUS_NO_LDT (279)
+#define NT_STATUS_INVALID_LDT_SIZE (280)
+#define NT_STATUS_INVALID_LDT_OFFSET (281)
+#define NT_STATUS_INVALID_LDT_DESCRIPTOR (282)
+#define NT_STATUS_INVALID_IMAGE_NE_FORMAT (283)
+#define NT_STATUS_RXACT_INVALID_STATE (284)
+#define NT_STATUS_RXACT_COMMIT_FAILURE (285)
+#define NT_STATUS_MAPPED_FILE_SIZE_ZERO (286)
+#define NT_STATUS_TOO_MANY_OPENED_FILES (287)
+#define NT_STATUS_CANCELLED (288)
+#define NT_STATUS_CANNOT_DELETE (289)
+#define NT_STATUS_INVALID_COMPUTER_NAME (290)
+#define NT_STATUS_FILE_DELETED (291)
+#define NT_STATUS_SPECIAL_ACCOUNT (292)
+#define NT_STATUS_SPECIAL_GROUP (293)
+#define NT_STATUS_SPECIAL_USER (294)
+#define NT_STATUS_MEMBERS_PRIMARY_GROUP (295)
+#define NT_STATUS_FILE_CLOSED (296)
+#define NT_STATUS_TOO_MANY_THREADS (297)
+#define NT_STATUS_THREAD_NOT_IN_PROCESS (298)
+#define NT_STATUS_TOKEN_ALREADY_IN_USE (299)
+#define NT_STATUS_PAGEFILE_QUOTA_EXCEEDED (300)
+#define NT_STATUS_COMMITMENT_LIMIT (301)
+#define NT_STATUS_INVALID_IMAGE_LE_FORMAT (302)
+#define NT_STATUS_INVALID_IMAGE_NOT_MZ (303)
+#define NT_STATUS_INVALID_IMAGE_PROTECT (304)
+#define NT_STATUS_INVALID_IMAGE_WIN_16 (305)
+#define NT_STATUS_LOGON_SERVER_CONFLICT (306)
+#define NT_STATUS_TIME_DIFFERENCE_AT_DC (307)
+#define NT_STATUS_SYNCHRONIZATION_REQUIRED (308)
+#define NT_STATUS_DLL_NOT_FOUND (309)
+#define NT_STATUS_OPEN_FAILED (310)
+#define NT_STATUS_IO_PRIVILEGE_FAILED (311)
+#define NT_STATUS_ORDINAL_NOT_FOUND (312)
+#define NT_STATUS_ENTRYPOINT_NOT_FOUND (313)
+#define NT_STATUS_CONTROL_C_EXIT (314)
+#define NT_STATUS_LOCAL_DISCONNECT (315)
+#define NT_STATUS_REMOTE_DISCONNECT (316)
+#define NT_STATUS_REMOTE_RESOURCES (317)
+#define NT_STATUS_LINK_FAILED (318)
+#define NT_STATUS_LINK_TIMEOUT (319)
+#define NT_STATUS_INVALID_CONNECTION (320)
+#define NT_STATUS_INVALID_ADDRESS (321)
+#define NT_STATUS_DLL_INIT_FAILED (322)
+#define NT_STATUS_MISSING_SYSTEMFILE (323)
+#define NT_STATUS_UNHANDLED_EXCEPTION (324)
+#define NT_STATUS_APP_INIT_FAILURE (325)
+#define NT_STATUS_PAGEFILE_CREATE_FAILED (326)
+#define NT_STATUS_NO_PAGEFILE (327)
+#define NT_STATUS_INVALID_LEVEL (328)
+#define NT_STATUS_WRONG_PASSWORD_CORE (329)
+#define NT_STATUS_ILLEGAL_FLOAT_CONTEXT (330)
+#define NT_STATUS_PIPE_BROKEN (331)
+#define NT_STATUS_REGISTRY_CORRUPT (332)
+#define NT_STATUS_REGISTRY_IO_FAILED (333)
+#define NT_STATUS_NO_EVENT_PAIR (334)
+#define NT_STATUS_UNRECOGNIZED_VOLUME (335)
+#define NT_STATUS_SERIAL_NO_DEVICE_INITED (336)
+#define NT_STATUS_NO_SUCH_ALIAS (337)
+#define NT_STATUS_MEMBER_NOT_IN_ALIAS (338)
+#define NT_STATUS_MEMBER_IN_ALIAS (339)
+#define NT_STATUS_ALIAS_EXISTS (340)
+#define NT_STATUS_LOGON_NOT_GRANTED (341)
+#define NT_STATUS_TOO_MANY_SECRETS (342)
+#define NT_STATUS_SECRET_TOO_LONG (343)
+#define NT_STATUS_INTERNAL_DB_ERROR (344)
+#define NT_STATUS_FULLSCREEN_MODE (345)
+#define NT_STATUS_TOO_MANY_CONTEXT_IDS (346)
+#define NT_STATUS_LOGON_TYPE_NOT_GRANTED (347)
+#define NT_STATUS_NOT_REGISTRY_FILE (348)
+#define NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED (349)
+#define NT_STATUS_DOMAIN_CTRLR_CONFIG_ERROR (350)
+#define NT_STATUS_FT_MISSING_MEMBER (351)
+#define NT_STATUS_ILL_FORMED_SERVICE_ENTRY (352)
+#define NT_STATUS_ILLEGAL_CHARACTER (353)
+#define NT_STATUS_UNMAPPABLE_CHARACTER (354)
+#define NT_STATUS_UNDEFINED_CHARACTER (355)
+#define NT_STATUS_FLOPPY_VOLUME (356)
+#define NT_STATUS_FLOPPY_ID_MARK_NOT_FOUND (357)
+#define NT_STATUS_FLOPPY_WRONG_CYLINDER (358)
+#define NT_STATUS_FLOPPY_UNKNOWN_ERROR (359)
+#define NT_STATUS_FLOPPY_BAD_REGISTERS (360)
+#define NT_STATUS_DISK_RECALIBRATE_FAILED (361)
+#define NT_STATUS_DISK_OPERATION_FAILED (362)
+#define NT_STATUS_DISK_RESET_FAILED (363)
+#define NT_STATUS_SHARED_IRQ_BUSY (364)
+#define NT_STATUS_FT_ORPHANING (365)
+#define NT_STATUS_PARTITION_FAILURE (370)
+#define NT_STATUS_INVALID_BLOCK_LENGTH (371)
+#define NT_STATUS_DEVICE_NOT_PARTITIONED (372)
+#define NT_STATUS_UNABLE_TO_LOCK_MEDIA (373)
+#define NT_STATUS_UNABLE_TO_UNLOAD_MEDIA (374)
+#define NT_STATUS_EOM_OVERFLOW (375)
+#define NT_STATUS_NO_MEDIA (376)
+#define NT_STATUS_NO_SUCH_MEMBER (378)
+#define NT_STATUS_INVALID_MEMBER (379)
+#define NT_STATUS_KEY_DELETED (380)
+#define NT_STATUS_NO_LOG_SPACE (381)
+#define NT_STATUS_TOO_MANY_SIDS (382)
+#define NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED (383)
+#define NT_STATUS_KEY_HAS_CHILDREN (384)
+#define NT_STATUS_CHILD_MUST_BE_VOLATILE (385)
+#define NT_STATUS_DEVICE_CONFIGURATION_ERROR (386)
+#define NT_STATUS_DRIVER_INTERNAL_ERROR (387)
+#define NT_STATUS_INVALID_DEVICE_STATE (388)
+#define NT_STATUS_IO_DEVICE_ERROR (389)
+#define NT_STATUS_DEVICE_PROTOCOL_ERROR (390)
+#define NT_STATUS_BACKUP_CONTROLLER (391)
+#define NT_STATUS_LOG_FILE_FULL (392)
+#define NT_STATUS_TOO_LATE (393)
+#define NT_STATUS_NO_TRUST_LSA_SECRET (394)
+#define NT_STATUS_NO_TRUST_SAM_ACCOUNT (395)
+#define NT_STATUS_TRUSTED_DOMAIN_FAILURE (396)
+#define NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE (397)
+#define NT_STATUS_EVENTLOG_FILE_CORRUPT (398)
+#define NT_STATUS_EVENTLOG_CANT_START (399)
+#define NT_STATUS_TRUST_FAILURE (400)
+#define NT_STATUS_MUTANT_LIMIT_EXCEEDED (401)
+#define NT_STATUS_NETLOGON_NOT_STARTED (402)
+#define NT_STATUS_ACCOUNT_EXPIRED (403)
+#define NT_STATUS_POSSIBLE_DEADLOCK (404)
+#define NT_STATUS_NETWORK_CREDENTIAL_CONFLICT (405)
+#define NT_STATUS_REMOTE_SESSION_LIMIT (406)
+#define NT_STATUS_EVENTLOG_FILE_CHANGED (407)
+#define NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT (408)
+#define NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT (409)
+#define NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT (410)
+#define NT_STATUS_DOMAIN_TRUST_INCONSISTENT (411)
+#define NT_STATUS_FS_DRIVER_REQUIRED (412)
+#define NT_STATUS_NO_USER_SESSION_KEY (514)
+#define NT_STATUS_USER_SESSION_DELETED (515)
+#define NT_STATUS_RESOURCE_LANG_NOT_FOUND (516)
+#define NT_STATUS_INSUFF_SERVER_RESOURCES (517)
+#define NT_STATUS_INVALID_BUFFER_SIZE (518)
+#define NT_STATUS_INVALID_ADDRESS_COMPONENT (519)
+#define NT_STATUS_INVALID_ADDRESS_WILDCARD (520)
+#define NT_STATUS_TOO_MANY_ADDRESSES (521)
+#define NT_STATUS_ADDRESS_ALREADY_EXISTS (522)
+#define NT_STATUS_ADDRESS_CLOSED (523)
+#define NT_STATUS_CONNECTION_DISCONNECTED (524)
+#define NT_STATUS_CONNECTION_RESET (525)
+#define NT_STATUS_TOO_MANY_NODES (526)
+#define NT_STATUS_TRANSACTION_ABORTED (527)
+#define NT_STATUS_TRANSACTION_TIMED_OUT (528)
+#define NT_STATUS_TRANSACTION_NO_RELEASE (529)
+#define NT_STATUS_TRANSACTION_NO_MATCH (530)
+#define NT_STATUS_TRANSACTION_RESPONDED (531)
+#define NT_STATUS_TRANSACTION_INVALID_ID (532)
+#define NT_STATUS_TRANSACTION_INVALID_TYPE (533)
+#define NT_STATUS_NOT_SERVER_SESSION (534)
+#define NT_STATUS_NOT_CLIENT_SESSION (535)
+#define NT_STATUS_CANNOT_LOAD_REGISTRY_FILE (536)
+#define NT_STATUS_DEBUG_ATTACH_FAILED (537)
+#define NT_STATUS_SYSTEM_PROCESS_TERMINATED (538)
+#define NT_STATUS_DATA_NOT_ACCEPTED (539)
+#define NT_STATUS_NO_BROWSER_SERVERS_FOUND (540)
+#define NT_STATUS_VDM_HARD_ERROR (541)
+#define NT_STATUS_DRIVER_CANCEL_TIMEOUT (542)
+#define NT_STATUS_REPLY_MESSAGE_MISMATCH (543)
+#define NT_STATUS_MAPPED_ALIGNMENT (544)
+#define NT_STATUS_IMAGE_CHECKSUM_MISMATCH (545)
+#define NT_STATUS_LOST_WRITEBEHIND_DATA (546)
+#define NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID (547)
+#define NT_STATUS_PASSWORD_MUST_CHANGE (548)
+#define NT_STATUS_NOT_FOUND (549)
+#define NT_STATUS_NOT_TINY_STREAM (550)
+#define NT_STATUS_RECOVERY_FAILURE (551)
+#define NT_STATUS_STACK_OVERFLOW_READ (552)
+#define NT_STATUS_FAIL_CHECK (553)
+#define NT_STATUS_DUPLICATE_OBJECTID (554)
+#define NT_STATUS_OBJECTID_EXISTS (555)
+#define NT_STATUS_CONVERT_TO_LARGE (556)
+#define NT_STATUS_RETRY (557)
+#define NT_STATUS_FOUND_OUT_OF_SCOPE (558)
+#define NT_STATUS_ALLOCATE_BUCKET (559)
+#define NT_STATUS_PROPSET_NOT_FOUND (560)
+#define NT_STATUS_MARSHALL_OVERFLOW (561)
+#define NT_STATUS_INVALID_VARIANT (562)
+#define NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND (563)
+#define NT_STATUS_ACCOUNT_LOCKED_OUT (564)
+#define NT_STATUS_HANDLE_NOT_CLOSABLE (565)
+#define NT_STATUS_CONNECTION_REFUSED (566)
+#define NT_STATUS_GRACEFUL_DISCONNECT (567)
+#define NT_STATUS_ADDRESS_ALREADY_ASSOCIATED (568)
+#define NT_STATUS_ADDRESS_NOT_ASSOCIATED (569)
+#define NT_STATUS_CONNECTION_INVALID (570)
+#define NT_STATUS_CONNECTION_ACTIVE (571)
+#define NT_STATUS_NETWORK_UNREACHABLE (572)
+#define NT_STATUS_HOST_UNREACHABLE (573)
+#define NT_STATUS_PROTOCOL_UNREACHABLE (574)
+#define NT_STATUS_PORT_UNREACHABLE (575)
+#define NT_STATUS_REQUEST_ABORTED (576)
+#define NT_STATUS_CONNECTION_ABORTED (577)
+#define NT_STATUS_BAD_COMPRESSION_BUFFER (578)
+#define NT_STATUS_USER_MAPPED_FILE (579)
+#define NT_STATUS_AUDIT_FAILED (580)
+#define NT_STATUS_TIMER_RESOLUTION_NOT_SET (581)
+#define NT_STATUS_CONNECTION_COUNT_LIMIT (582)
+#define NT_STATUS_LOGIN_TIME_RESTRICTION (583)
+#define NT_STATUS_LOGIN_WKSTA_RESTRICTION (584)
+#define NT_STATUS_IMAGE_MP_UP_MISMATCH (585)
+#define NT_STATUS_INSUFFICIENT_LOGON_INFO (592)
+#define NT_STATUS_BAD_DLL_ENTRYPOINT (593)
+#define NT_STATUS_BAD_SERVICE_ENTRYPOINT (594)
+#define NT_STATUS_LPC_REPLY_LOST (595)
+#define NT_STATUS_IP_ADDRESS_CONFLICT1 (596)
+#define NT_STATUS_IP_ADDRESS_CONFLICT2 (597)
+#define NT_STATUS_REGISTRY_QUOTA_LIMIT (598)
+#define NT_STATUS_PATH_NOT_COVERED (599)
+#define NT_STATUS_NO_CALLBACK_ACTIVE (600)
+#define NT_STATUS_LICENSE_QUOTA_EXCEEDED (601)
+#define NT_STATUS_PWD_TOO_SHORT (602)
+#define NT_STATUS_PWD_TOO_RECENT (603)
+#define NT_STATUS_PWD_HISTORY_CONFLICT (604)
+#define NT_STATUS_PLUGPLAY_NO_DEVICE (606)
+#define NT_STATUS_UNSUPPORTED_COMPRESSION (607)
+#define NT_STATUS_INVALID_HW_PROFILE (608)
+#define NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH (609)
+#define NT_STATUS_DRIVER_ORDINAL_NOT_FOUND (610)
+#define NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND (611)
+#define NT_STATUS_RESOURCE_NOT_OWNED (612)
+#define NT_STATUS_TOO_MANY_LINKS (613)
+#define NT_STATUS_QUOTA_LIST_INCONSISTENT (614)
+#define NT_STATUS_FILE_IS_OFFLINE (615)
--
cgit
From 0eb9a590430c328e6ebc46ff8ab05f181921769a Mon Sep 17 00:00:00 2001
From: Andrew Tridgell
Date: Sat, 4 Oct 1997 05:21:14 +0000
Subject: a little hack to smbclient to support extracting NT error codes
---
source/client/client.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/source/client/client.c b/source/client/client.c
index 275d03ddba2..403eea2fc99 100644
--- a/source/client/client.c
+++ b/source/client/client.c
@@ -275,6 +275,18 @@ static BOOL chkpath(char *path,BOOL report)
*p++ = 4;
strcpy(p,path2);
+#if 0
+ {
+ /* this little bit of code can be used to extract NT error codes.
+ Just feed a bunch of "cd foo" commands to smbclient then watch
+ in netmon (tridge) */
+ static int code=0;
+ SIVAL(outbuf, smb_rcls, code | 0xC0000000);
+ SSVAL(outbuf, smb_flg2, SVAL(outbuf, smb_flg2) | (1<<14));
+ code++;
+ }
+#endif
+
send_smb(Client,outbuf);
receive_smb(Client,inbuf,CLIENT_TIMEOUT);
--
cgit
From d40199f4fe1344058267859820cb36b77a20442a Mon Sep 17 00:00:00 2001
From: Andrew Tridgell
Date: Sat, 4 Oct 1997 05:21:47 +0000
Subject: a bit of bounds checking
---
source/client/clientutil.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/source/client/clientutil.c b/source/client/clientutil.c
index d16e5a471fc..ed5497782b3 100644
--- a/source/client/clientutil.c
+++ b/source/client/clientutil.c
@@ -126,6 +126,13 @@ BOOL cli_receive_trans_response(char *inbuf,int trans,int *data_len,
{
this_data = SVAL(inbuf,smb_drcnt);
this_param = SVAL(inbuf,smb_prcnt);
+
+ if (this_data + *data_len > total_data ||
+ this_param + *param_len > total_param) {
+ DEBUG(1,("Data overflow in cli_receive_trans_response\n"));
+ return False;
+ }
+
if (this_data)
memcpy(*data + SVAL(inbuf,smb_drdisp),
smb_base(inbuf) + SVAL(inbuf,smb_droff),
@@ -453,6 +460,11 @@ BOOL cli_send_login(char *inbuf, char *outbuf, BOOL start_session, BOOL use_setu
/* send a session setup command */
bzero(outbuf,smb_size);
+ if (passlen > MAX_PASSWORD_LENGTH) {
+ DEBUG(1,("password too long %d\n", passlen));
+ return False;
+ }
+
if (Protocol < PROTOCOL_NT1) {
set_message(outbuf,10,1 + strlen(username) + passlen,True);
CVAL(outbuf,smb_com) = SMBsesssetupX;
--
cgit
From 25b7ada3587d1fe68164a2339d7f0fbcecf18e53 Mon Sep 17 00:00:00 2001
From: Andrew Tridgell
Date: Sat, 4 Oct 1997 05:24:02 +0000
Subject: fix some "shadows global" errors.
---
source/smbd/server.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/source/smbd/server.c b/source/smbd/server.c
index b250572a1f4..826b17121fd 100644
--- a/source/smbd/server.c
+++ b/source/smbd/server.c
@@ -2441,7 +2441,7 @@ static void process_smb(char *inbuf, char *outbuf)
static BOOL open_oplock_ipc()
{
struct sockaddr_in sock_name;
- int name_len = sizeof(sock_name);
+ int len = sizeof(sock_name);
DEBUG(3,("open_oplock_ipc: opening loopback UDP socket.\n"));
@@ -2456,7 +2456,7 @@ address %x. Error was %s\n", htonl(INADDR_LOOPBACK), strerror(errno)));
}
/* Find out the transient UDP port we have been allocated. */
- if(getsockname(oplock_sock, (struct sockaddr *)&sock_name, &name_len)<0)
+ if(getsockname(oplock_sock, (struct sockaddr *)&sock_name, &len)<0)
{
DEBUG(0,("open_oplock_ipc: Failed to get local UDP port. Error was %s\n",
strerror(errno)));
@@ -2473,7 +2473,7 @@ address %x. Error was %s\n", htonl(INADDR_LOOPBACK), strerror(errno)));
/****************************************************************************
process an oplock break message.
****************************************************************************/
-static BOOL process_local_message(int oplock_sock, char *buffer, int buf_size)
+static BOOL process_local_message(int sock, char *buffer, int buf_size)
{
int32 msg_len;
int16 from_port;
@@ -2543,7 +2543,7 @@ oplocks. Returning success.\n"));
toaddr.sin_port = htons(from_port);
toaddr.sin_family = AF_INET;
- if(sendto( oplock_sock, msg_start, OPLOCK_BREAK_MSG_LEN, 0,
+ if(sendto( sock, msg_start, OPLOCK_BREAK_MSG_LEN, 0,
(struct sockaddr *)&toaddr, sizeof(toaddr)) < 0)
{
DEBUG(0,("process_local_message: sendto process %d failed. Errno was %s\n",
--
cgit
From 297d5ef46ccba99596610c4c6a09399af665f2cf Mon Sep 17 00:00:00 2001
From: Luke Leighton
Date: Sat, 4 Oct 1997 16:10:21 +0000
Subject: packet parsing routines. for use in SMB and Mailslots
---
source/smbparse.c | 385 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 385 insertions(+)
create mode 100644 source/smbparse.c
diff --git a/source/smbparse.c b/source/smbparse.c
new file mode 100644
index 00000000000..bff1a1453a4
--- /dev/null
+++ b/source/smbparse.c
@@ -0,0 +1,385 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Samba utility functions
+ Copyright (C) Luke Leighton 1996 - 1997
+
+ 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"
+
+extern int DEBUGLEVEL;
+
+
+/*******************************************************************
+reads or writes an NTTIME structure.
+********************************************************************/
+char* smb_io_time(BOOL io, NTTIME *nttime, char *q, char *base, int align)
+{
+ if (nttime == NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ RW_IVAL(io, q, nttime->low , 0); q += 4; /* low part */
+ RW_IVAL(io, q, nttime->high, 0); q += 4; /* high part */
+
+ return q;
+}
+
+/*******************************************************************
+reads or writes a DOM_SID structure.
+********************************************************************/
+char* smb_io_sid(BOOL io, DOM_SID *sid, char *q, char *base, int align)
+{
+ int i;
+
+ if (sid == NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ RW_CVAL(io, q, sid->sid_no, 0); q++;
+ RW_CVAL(io, q, sid->num_auths, 0); q++;
+
+ for (i = 0; i < 6; i++)
+ {
+ RW_CVAL(io, q, sid->id_auth[i], 0); q++;
+ }
+
+ /* oops! XXXX should really issue a warning here... */
+ if (sid->num_auths > MAXSUBAUTHS) sid->num_auths = MAXSUBAUTHS;
+
+ RW_PSVAL(io, q, sid->sub_auths, sid->num_auths); q += sid->num_auths * 2;
+
+ return q;
+}
+
+/*******************************************************************
+reads or writes a UNIHDR structure.
+********************************************************************/
+char* smb_io_unihdr(BOOL io, UNIHDR *hdr, char *q, char *base, int align)
+{
+ if (hdr == NULL) return NULL;
+
+ /* should be value 4, so enforce it. */
+ hdr->undoc = 4;
+
+ q = align_offset(q, base, align);
+
+ RW_IVAL(io, q, hdr->uni_max_len, 0); q += 4;
+ RW_IVAL(io, q, hdr->uni_str_len, 0); q += 4;
+ RW_IVAL(io, q, hdr->undoc , 0); q += 4;
+
+ return q;
+}
+
+/*******************************************************************
+reads or writes a UNIHDR2 structure.
+********************************************************************/
+char* smb_io_unihdr2(BOOL io, UNIHDR2 *hdr2, char *q, char *base, int align)
+{
+ if (hdr2 == NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ q = smb_io_unihdr(io, &(hdr2->unihdr), q, base, align);
+ RW_IVAL(io, q, hdr2->undoc_buffer, 0); q += 4;
+
+ return q;
+}
+
+/*******************************************************************
+reads or writes a UNISTR structure.
+XXXX NOTE: UNISTR structures NEED to be null-terminated.
+********************************************************************/
+char* smb_io_unistr(BOOL io, UNISTR *uni, char *q, char *base, int align)
+{
+ if (uni == NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ if (io)
+ {
+ /* io True indicates read _from_ the SMB buffer into the string */
+ q += 2 * unistrcpy((char*)uni->buffer, q);
+ }
+ else
+ {
+ /* io True indicates copy _from_ the string into SMB buffer */
+ q += 2 * unistrcpy(q, (char*)uni->buffer);
+ }
+ return q;
+}
+
+/*******************************************************************
+reads or writes a UNISTR2 structure.
+XXXX NOTE: UNISTR2 structures need NOT be null-terminated.
+ the uni_str_len member tells you how long the string is;
+ the uni_max_len member tells you how large the buffer is.
+********************************************************************/
+char* smb_io_unistr2(BOOL io, UNISTR2 *uni2, char *q, char *base, int align)
+{
+ if (uni2 == NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ /* should be value 0, so enforce it. */
+ uni2->undoc = 0;
+
+ RW_IVAL(io, q, uni2->uni_max_len, 0); q += 4;
+ RW_IVAL(io, q, uni2->undoc , 0); q += 4;
+ RW_IVAL(io, q, uni2->uni_str_len, 0); q += 4;
+
+ /* oops! XXXX maybe issue a warning that this is happening... */
+ if (uni2->uni_max_len > MAX_UNISTRLEN) uni2->uni_max_len = MAX_UNISTRLEN;
+ if (uni2->uni_str_len > MAX_UNISTRLEN) uni2->uni_str_len = MAX_UNISTRLEN;
+
+ /* buffer advanced by indicated length of string
+ NOT by searching for null-termination */
+ RW_PSVAL(io, q, uni2->buffer, uni2->uni_max_len); q += uni2->uni_max_len * 2;
+
+ return q;
+}
+
+/*******************************************************************
+reads or writes a DOM_SID2 structure.
+********************************************************************/
+char* smb_io_dom_sid2(BOOL io, DOM_SID2 *sid2, char *q, char *base, int align)
+{
+ if (sid2 == NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ /* should be value 5, so enforce it */
+ sid2->type = 5;
+
+ /* should be value 0, so enforce it */
+ sid2->undoc = 0;
+
+ RW_IVAL(io, q, sid2->type , 0); q += 4;
+ RW_IVAL(io, q, sid2->undoc, 0); q += 4;
+
+ q = smb_io_unihdr2(io, &(sid2->hdr), q, base, align);
+ q = smb_io_unistr (io, &(sid2->str), q, base, align);
+
+ return q;
+}
+
+/*******************************************************************
+reads or writes a DOM_RID2 structure.
+********************************************************************/
+char* smb_io_dom_rid2(BOOL io, DOM_RID2 *rid2, char *q, char *base, int align)
+{
+ if (rid2 == NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ /* should be value 5, so enforce it */
+ rid2->type = 5;
+
+ /* should be value 5, so enforce it */
+ rid2->undoc = 5;
+
+ RW_IVAL(io, q, rid2->type, 0); q += 4;
+ RW_IVAL(io, q, rid2->undoc , 0); q += 4;
+ RW_IVAL(io, q, rid2->rid , 0); q += 4;
+ RW_IVAL(io, q, rid2->rid_idx , 0); q += 4;
+
+ return q;
+}
+
+/*******************************************************************
+reads or writes a DOM_LOG_INFO structure.
+********************************************************************/
+char* smb_io_log_info(BOOL io, DOM_LOG_INFO *log, char *q, char *base, int align)
+{
+ if (log == NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ RW_IVAL(io, q, log->undoc_buffer, 0); q += 4;
+
+ q = smb_io_unistr2(io, &(log->uni_logon_srv), q, base, align);
+ q = smb_io_unistr2(io, &(log->uni_acct_name), q, base, align);
+
+ RW_SVAL(io, q, log->sec_chan, 0); q += 2;
+
+ /* XXXX no alignment required between sec_chan and uni_comp_name */
+ q = smb_io_unistr2(io, &(log->uni_comp_name), q, base, 0);
+
+ return q;
+}
+
+/*******************************************************************
+reads or writes a DOM_CRED structure.
+********************************************************************/
+char* smb_io_cred(BOOL io, DOM_CRED *cred, char *q, char *base, int align)
+{
+ if (cred == NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ RW_PCVAL(io, q, cred->data, 8); q += 8;
+ RW_IVAL (io, q, cred->timestamp, 0); q += 4;
+
+ return q;
+}
+
+/*******************************************************************
+reads or writes a DOM_CLNT_INFO structure.
+********************************************************************/
+char* smb_io_clnt_info(BOOL io, DOM_CLNT_INFO *clnt, char *q, char *base, int align)
+{
+ if (clnt == NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ q = smb_io_log_info(io, &(clnt->login), q, base, align);
+ q = smb_io_cred (io, &(clnt->cred ), q, base, align);
+
+ return q;
+}
+
+/*******************************************************************
+reads or writes a DOM_LOGON_ID structure.
+********************************************************************/
+char* smb_io_logon_id(BOOL io, DOM_LOGON_ID *log, char *q, char *base, int align)
+{
+ if (log == NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ RW_IVAL(io, q, log->low , 0); q += 4;
+ RW_IVAL(io, q, log->high, 0); q += 4;
+
+ return q;
+}
+
+/*******************************************************************
+reads or writes an RC4_OWF structure.
+********************************************************************/
+char* smb_io_rc4_owf(BOOL io, RC4_OWF *hash, char *q, char *base, int align)
+{
+ if (hash == NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ RW_PCVAL(io, q, hash->data, 16); q += 16;
+
+ return q;
+}
+
+/*******************************************************************
+reads or writes an DOM_ID_INFO_1 structure.
+********************************************************************/
+char* smb_io_id_info1(BOOL io, DOM_ID_INFO_1 *id, char *q, char *base, int align)
+{
+ if (id == NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ q = smb_io_unihdr(io, &(id->hdr_domain_name ), q, base, align);
+
+ RW_IVAL(io, q, id->param, 0); q += 4;
+ q = smb_io_logon_id(io, &(id->logon_id), q, base, align);
+
+ q = smb_io_unihdr(io, &(id->hdr_user_name ), q, base, align);
+ q = smb_io_unihdr(io, &(id->hdr_workgroup_name), q, base, align);
+
+ q = smb_io_rc4_owf(io, &(id->rc4_lm_owf), q, base, align);
+ q = smb_io_rc4_owf(io, &(id->rc4_nt_owf), q, base, align);
+
+ q = smb_io_unistr2(io, &(id->uni_domain_name ), q, base, align);
+ q = smb_io_unistr2(io, &(id->uni_user_name ), q, base, align);
+ q = smb_io_unistr2(io, &(id->uni_workgroup_name), q, base, align);
+
+ return q;
+}
+
+/*******************************************************************
+reads or writes a DOM_SAM_INFO structure.
+********************************************************************/
+char* smb_io_sam_info(BOOL io, DOM_SAM_INFO *sam, char *q, char *base, int align)
+{
+ if (sam == NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ q = smb_io_clnt_info(io, &(sam->client ), q, base, align);
+ q = smb_io_cred (io, &(sam->rtn_cred), q, base, align);
+
+ RW_IVAL(io, q, sam->logon_level, 0); q += 4;
+ RW_SVAL(io, q, sam->auth_level , 0); q += 4;
+
+ switch (sam->auth_level)
+ {
+ case 1:
+ {
+ q = smb_io_id_info1(io, &(sam->auth.id1), q, base, align);
+ break;
+ }
+ default:
+ {
+ /* PANIC! */
+ break;
+ }
+ }
+ return q;
+}
+
+/*******************************************************************
+reads or writes a DOM_GID structure.
+********************************************************************/
+char* smb_io_gid(BOOL io, DOM_GID *gid, char *q, char *base, int align)
+{
+ if (gid == NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ RW_IVAL(io, q, gid->gid , 0); q += 4;
+ RW_IVAL(io, q, gid->attr, 0); q += 4;
+
+ return q;
+}
+
+#if 0
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+ char* smb_io_(BOOL io, *, char *q, char *base, int align)
+{
+ if (== NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ RW_IVAL(io, q, , 0); q += 4;
+
+ return q;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+ char* smb_io_(BOOL io, *, char *q, char *base, int align)
+{
+ if (== NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ RW_IVAL(io, q, , 0); q += 4;
+
+ return q;
+}
+#endif
--
cgit
From 4b3f9b281b3b1c1064992d19fef1d782dc6f1ff1 Mon Sep 17 00:00:00 2001
From: Luke Leighton
Date: Sat, 4 Oct 1997 16:26:02 +0000
Subject: added structures readable and writeable by smbparse.c routines into
and out of SMB or Mailslot packets.
---
source/include/smb.h | 182 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 182 insertions(+)
diff --git a/source/include/smb.h b/source/include/smb.h
index 66da2099c77..37474436cac 100644
--- a/source/include/smb.h
+++ b/source/include/smb.h
@@ -252,6 +252,188 @@ typedef char fstring[128];
typedef fstring string;
+/* 32 bit time (sec) since 01jan1970 - cifs6.txt, section 3.5, page 30 */
+typedef uint32 UTIME;
+
+/* 64 bit time (100usec) since ????? - cifs6.txt, section 3.5, page 30 */
+typedef struct nttime
+{
+ uint32 low;
+ uint32 high;
+
+} NTTIME;
+
+
+#define MAXSUBAUTHS 10 /* max sub authorities in a SID */
+
+/* DOM_SID - security id */
+typedef struct sid_info
+{
+ uint8 sid_no; /* SID revision number */
+ uint8 num_auths; /* number of sub-authorities */
+ uint8 id_auth[6]; /* Identifier Authority */
+ uint16 sub_auths[MAXSUBAUTHS]; /* pointer to sub-authorities. */
+
+} DOM_SID;
+
+/* UNIHDR - unicode string header */
+typedef struct unihdr_info
+{
+ uint16 uni_max_len;
+ uint16 uni_str_len;
+ uint32 undoc; /* usually has a value of 4 */
+
+} UNIHDR;
+
+/* UNIHDR2 - unicode string header and undocumented buffer */
+typedef struct unihdr2_info
+{
+ UNIHDR unihdr;
+ uint32 undoc_buffer; /* undocumented 32 bit buffer pointer */
+
+} UNIHDR2;
+
+/* clueless as to what maximum length should be */
+#define MAX_UNISTRLEN 1024
+
+/* UNISTR - unicode string size and buffer */
+typedef struct unistr_info
+{
+ uint16 buffer[MAX_UNISTRLEN]; /* unicode characters. ***MUST*** be null-terminated */
+
+} UNISTR;
+
+/* UNISTR2 - unicode string size and buffer */
+typedef struct unistr2_info
+{
+ uint32 uni_max_len;
+ uint32 undoc;
+ uint32 uni_str_len;
+ uint16 buffer[MAX_UNISTRLEN]; /* unicode characters. **NOT** necessarily null-terminated */
+
+} UNISTR2;
+
+/* DOM_SID2 - domain SID structure - SIDs stored in unicode */
+typedef struct domsid2_info
+{
+ uint32 type; /* value is 5 */
+ uint32 undoc; /* value is 0 */
+ UNIHDR2 hdr; /* XXXX conflict between hdr and str for length */
+ UNISTR str; /* XXXX conflict between hdr and str for length */
+
+} DOM_SID2;
+
+/* DOM_RID2 - domain RID structure */
+typedef struct domrid2_info
+{
+ uint32 type; /* value is 5 */
+ uint32 undoc; /* value is 5 */
+ uint32 rid;
+ uint32 rid_idx; /* don't know what this is */
+
+} DOM_RID2;
+
+/* DOM_LOG_INFO - login info */
+typedef struct log_info
+{
+ uint32 undoc_buffer; /* undocumented 32 bit buffer pointer */
+ UNISTR2 uni_logon_srv; /* logon server name */
+ UNISTR2 uni_acct_name; /* account name */
+ uint16 sec_chan; /* secure channel type */
+ UNISTR2 uni_comp_name; /* client machine name */
+
+} DOM_LOG_INFO;
+
+/* DOM_CREDs - client or server credentials */
+typedef struct cred_info
+{
+ uint8 data[8]; /* credentials */
+ UTIME timestamp; /* credential time-stamp */
+
+} DOM_CRED;
+
+/* DOM_CLNT_INFO - client info */
+typedef struct clnt_info
+{
+ DOM_LOG_INFO login;
+ DOM_CRED cred;
+
+} DOM_CLNT_INFO;
+
+/* DOM_LOGON_ID - logon id */
+typedef struct logon_info
+{
+ uint32 low;
+ uint32 high;
+
+} DOM_LOGON_ID;
+
+/* RC4_OWF */
+typedef struct rc4_owf_info
+{
+ uint8 data[16];
+
+} RC4_OWF;
+
+
+/* DOM_ID_INFO_1 */
+typedef struct id_info_1
+{
+ UNIHDR hdr_domain_name; /* domain name unicode header */
+ uint32 param; /* param control */
+ DOM_LOGON_ID logon_id; /* logon ID */
+ UNIHDR hdr_user_name; /* user name unicode header */
+ UNIHDR hdr_workgroup_name; /* workgroup name unicode header */
+ RC4_OWF rc4_lm_owf; /* rc4 LM OWF Password */
+ RC4_OWF rc4_nt_owf; /* rc4 NT OWF Password */
+ UNISTR2 uni_domain_name; /* domain name unicode string */
+ UNISTR2 uni_user_name; /* user name unicode string */
+ UNISTR2 uni_workgroup_name; /* workgroup name unicode string */
+
+} DOM_ID_INFO_1;
+
+/* SAM_INFO - sam logon/off id structure */
+typedef struct sam_info
+{
+ DOM_CLNT_INFO client;
+ DOM_CRED rtn_cred; /* return credentials */
+ uint16 logon_level;
+ uint32 auth_level; /* undocumented */
+
+ union
+ {
+ DOM_ID_INFO_1 id1; /* auth-level 1 */
+
+ } auth;
+
+} DOM_SAM_INFO;
+
+/* DOM_GID - group id + user attributes */
+typedef struct gid_info
+{
+ uint32 gid; /* group id */
+ uint32 attr;
+
+} DOM_GID;
+
+/* RPC_HEADER - ms rpc header */
+typedef struct rpc_hdr_info
+{
+ uint8 major; /* 5 - RPC major version */
+ uint8 minor; /* 0 - RPC minor version */
+ uint8 pkt_type; /* 2 - RPC response packet */
+ uint8 frag; /* 3 - first frag + last frag */
+ uint32 pack_type; /* 0x0000 0010 - packed data representation */
+ uint16 frag_len; /* fragment length - data size (bytes) inc header and tail. */
+ uint16 auth_len; /* 0 - authentication length */
+ uint32 call_id; /* call identifier. matches 12th uint32 of incoming RPC data. */
+ uint32 alloc_hint; /* allocation hint - data size (bytes) minus header and tail. */
+ uint16 context_id; /* 0 - presentation context identifier */
+ uint8 cancel_count; /* 0 - cancel count */
+ uint8 reserved; /* 0 - reserved */
+} RPC_HEADER;
+
+
struct smb_passwd {
int smb_userid;
char *smb_name;
--
cgit
From b0ffd75acfd3660512cccecdf50a183c3abccfcb Mon Sep 17 00:00:00 2001
From: Luke Leighton
Date: Sat, 4 Oct 1997 16:42:09 +0000
Subject: added some RW_XXXX wrapper macros with an extra i/o argument, to call
XXXX or SXXXX as appropriate.
added some for-loop pointer macros that will do a batch of data into a
(fixed length) buffer. no length validation is done in the macro itself.
note: there are some CAREFUL_ALIGNMENT macros missing. i think.
---
source/include/byteorder.h | 49 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/source/include/byteorder.h b/source/include/byteorder.h
index a55789a4036..4991338f263 100644
--- a/source/include/byteorder.h
+++ b/source/include/byteorder.h
@@ -88,6 +88,28 @@ it also defines lots of intermediate macros, just ignore those :-)
*/
+/* some switch macros that do both store and read to and from SMB buffers */
+
+#define RW_PCVAL(read,inbuf,outbuf,len) \
+ if (read) { PCVAL (inbuf,0,outbuf,len) } \
+ else { PSCVAL(inbuf,0,outbuf,len) }
+
+#define RW_PSVAL(read,inbuf,outbuf,len) \
+ if (read) { PSVAL (inbuf,0,outbuf,len) } \
+ else { PSSVAL(inbuf,0,outbuf,len) }
+
+#define RW_CVAL(read, inbuf, outbuf, offset) \
+ if (read) (outbuf) = CVAL (inbuf,offset); \
+ else SCVAL(inbuf,offset,outbuf);
+
+#define RW_IVAL(read, inbuf, outbuf, offset) \
+ if (read) (outbuf)= IVAL (inbuf,offset); \
+ else SIVAL(inbuf,offset,outbuf);
+
+#define RW_SVAL(read, inbuf, outbuf, offset) \
+ if (read) (outbuf)= SVAL (inbuf,offset); \
+ else SSVAL(inbuf,offset,outbuf);
+
#undef CAREFUL_ALIGNMENT
/* we know that the 386 can handle misalignment and has the "right"
@@ -123,14 +145,41 @@ it also defines lots of intermediate macros, just ignore those :-)
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) (*(uint16 *)((char *)(buf) + (pos)))
#define IVAL(buf,pos) (*(uint32 *)((char *)(buf) + (pos)))
#define SVALS(buf,pos) (*(int16 *)((char *)(buf) + (pos)))
#define IVALS(buf,pos) (*(int32 *)((char *)(buf) + (pos)))
+
+/* store single value in an SMB buffer */
#define SSVAL(buf,pos,val) SVAL(buf,pos)=((uint16)(val))
#define SIVAL(buf,pos,val) IVAL(buf,pos)=((uint32)(val))
#define SSVALS(buf,pos,val) SVALS(buf,pos)=((int16)(val))
#define SIVALS(buf,pos,val) IVALS(buf,pos)=((int32)(val))
+
+#define SMBMACRO(macro,buf,pos,val,len,size) \
+{ int l; for (l = 0; l < (len); l++) (val)[l] = macro((buf), (pos) + (size)*l); }
+
+#define SSMBMACRO(macro,buf,pos,val,len,size) \
+{ int l; for (l = 0; l < (len); l++) macro((buf), (pos) + (size)*l, (val)[l]); }
+
+/* reads multiple data from an SMB buffer */
+#define PCVAL(buf,pos,val,len) SMBMACRO(CVAL,buf,pos,val,len,1)
+#define PSVAL(buf,pos,val,len) SMBMACRO(SVAL,buf,pos,val,len,2)
+#define PIVAL(buf,pos,val,len) SMBMACRO(IVAL,buf,pos,val,len,4)
+#define PCVALS(buf,pos,val,len) SMBMACRO(CVALS,buf,pos,val,len,1)
+#define PSVALS(buf,pos,val,len) SMBMACRO(SVALS,buf,pos,val,len,2)
+#define PIVALS(buf,pos,val,len) SMBMACRO(IVALS,buf,pos,val,len,4)
+
+/* stores multiple data in an SMB buffer */
+#define PSCVAL(buf,pos,val,len) SSMBMACRO(SCVAL,buf,pos,val,len,1)
+#define PSSVAL(buf,pos,val,len) SSMBMACRO(SSVAL,buf,pos,val,len,2)
+#define PSIVAL(buf,pos,val,len) SSMBMACRO(SIVAL,buf,pos,val,len,4)
+#define PSCVALS(buf,pos,val,len) SSMBMACRO(SCVALS,buf,pos,val,len,1)
+#define PSSVALS(buf,pos,val,len) SSMBMACRO(SSVALS,buf,pos,val,len,2)
+#define PSIVALS(buf,pos,val,len) SSMBMACRO(SIVALS,buf,pos,val,len,4)
+
#endif
--
cgit
From b0ad811cda3dcffed5b24104229813cdb17b014f Mon Sep 17 00:00:00 2001
From: Luke Leighton
Date: Sat, 4 Oct 1997 16:51:43 +0000
Subject: proto.h:
- recreated, as usual.
smb.h:
- added RPC_HDR structure - the 18 byte MSRPC header
smbparse.c:
- added smb_io_rpc_hdr() function to read/write the RPC_HDR structure.
util.c:
- added align2, align4, align_offset functions.
- added skip_unicode_string, unistrcpy, unistrncpy functions.
- modified unistrcpy and unistrncpy to return the number of unicode
characters returned, effectively making skip_unicode_string redundant.
---
source/include/proto.h | 11 ++++-
source/include/smb.h | 8 +++-
source/lib/util.c | 113 +++++++++++++++++++++++++++++++++++++++++++++++++
source/smbparse.c | 27 ++++++++----
4 files changed, 148 insertions(+), 11 deletions(-)
diff --git a/source/include/proto.h b/source/include/proto.h
index 8818b9b5274..4ec4a42f2aa 100644
--- a/source/include/proto.h
+++ b/source/include/proto.h
@@ -565,7 +565,9 @@ void sync_browse_lists(struct subnet_record *d, struct work_record *work,
/*The following definitions come from params.c */
-BOOL pm_process(char *pszFileName,BOOL (*sfunc)(char *),BOOL (*pfunc)(char *,char *));
+BOOL pm_process( char *FileName,
+ BOOL (*sfunc)(char *),
+ BOOL (*pfunc)(char *, char *) );
/*The following definitions come from password.c */
@@ -986,5 +988,12 @@ void file_unlock(int fd);
BOOL is_myname(char *s);
void set_remote_arch(enum remote_arch_types type);
enum remote_arch_types get_remote_arch();
+char *skip_unicode_string(char *buf,int n);
+char *unistr(char *buf);
+int unistrncpy(char *dst, char *src, int len);
+int unistrcpy(char *dst, char *src);
void fstrcpy(char *dest, char *src);
void pstrcpy(char *dest, char *src);
+char *align4(char *q, char *base);
+char *align2(char *q, char *base);
+char *align_offset(char *q, char *base, int align_offset);
diff --git a/source/include/smb.h b/source/include/smb.h
index 37474436cac..b999c136677 100644
--- a/source/include/smb.h
+++ b/source/include/smb.h
@@ -80,6 +80,10 @@ typedef short int16;
typedef int int32;
#endif
+#ifndef uint8
+typedef unsigned char uint8;
+#endif
+
#ifndef uint16
typedef unsigned short uint16;
#endif
@@ -416,7 +420,7 @@ typedef struct gid_info
} DOM_GID;
-/* RPC_HEADER - ms rpc header */
+/* RPC_HDR - ms rpc header */
typedef struct rpc_hdr_info
{
uint8 major; /* 5 - RPC major version */
@@ -431,7 +435,7 @@ typedef struct rpc_hdr_info
uint16 context_id; /* 0 - presentation context identifier */
uint8 cancel_count; /* 0 - cancel count */
uint8 reserved; /* 0 - reserved */
-} RPC_HEADER;
+} RPC_HDR;
struct smb_passwd {
diff --git a/source/lib/util.c b/source/lib/util.c
index 01e2dae154c..c5cfdd99f75 100644
--- a/source/lib/util.c
+++ b/source/lib/util.c
@@ -4182,6 +4182,80 @@ enum remote_arch_types get_remote_arch()
return ra_type;
}
+
+/*******************************************************************
+skip past some unicode strings in a buffer
+********************************************************************/
+char *skip_unicode_string(char *buf,int n)
+{
+ while (n--)
+ {
+ while (*buf)
+ buf += 2;
+ buf += 2;
+ }
+ return(buf);
+}
+
+/*******************************************************************
+Return a ascii version of a unicode string
+Hack alert: uses fixed buffer and only handles ascii strings
+********************************************************************/
+#define MAXUNI 1024
+char *unistr(char *buf)
+{
+ static char lbufs[8][MAXUNI];
+ static int nexti;
+ char *lbuf = lbufs[nexti];
+ char *p;
+ nexti = (nexti+1)%8;
+ for (p = lbuf; *buf && p -lbuf < MAXUNI-2; p++, buf += 2)
+ *p = *buf;
+ *p = 0;
+ return lbuf;
+}
+
+/*******************************************************************
+strncpy for unicode strings
+********************************************************************/
+int unistrncpy(char *dst, char *src, int len)
+{
+ int num_wchars = 0;
+
+ while (*src && len > 0)
+ {
+ *dst++ = *src++;
+ *dst++ = *src++;
+ len--;
+ num_wchars++;
+ }
+ *dst++ = 0;
+ *dst++ = 0;
+
+ return num_wchars;
+}
+
+
+/*******************************************************************
+strcpy for unicode strings. returns length (in num of wide chars)
+********************************************************************/
+int unistrcpy(char *dst, char *src)
+{
+ int num_wchars = 0;
+
+ while (*src)
+ {
+ *dst++ = *src++;
+ *dst++ = *src++;
+ num_wchars++;
+ }
+ *dst++ = 0;
+ *dst++ = 0;
+
+ return num_wchars;
+}
+
+
/*******************************************************************
safe string copy into a fstring
********************************************************************/
@@ -4231,3 +4305,42 @@ void pstrcpy(char *dest, char *src)
strlen(src)));
}
}
+
+
+/*******************************************************************
+align a pointer to a multiple of 4 bytes
+********************************************************************/
+char *align4(char *q, char *base)
+{
+ if ((q - base) & 3)
+ {
+ q += 4 - ((q - base) & 3);
+ }
+ return q;
+}
+
+/*******************************************************************
+align a pointer to a multiple of 2 bytes
+********************************************************************/
+char *align2(char *q, char *base)
+{
+ if ((q - base) & 1)
+ {
+ q++;
+ }
+ return q;
+}
+
+/*******************************************************************
+align a pointer to a multiple of align_offset bytes. looks like it
+will work for offsets of 0, 2 and 4...
+********************************************************************/
+char *align_offset(char *q, char *base, int align_offset)
+{
+ if (align_offset != 0 && ((q - base) & (align_offset-1)))
+ {
+ q += align_offset - ((q - base) & (align_offset));
+ }
+ return q;
+}
+
diff --git a/source/smbparse.c b/source/smbparse.c
index bff1a1453a4..d39f18de5f4 100644
--- a/source/smbparse.c
+++ b/source/smbparse.c
@@ -354,21 +354,32 @@ char* smb_io_gid(BOOL io, DOM_GID *gid, char *q, char *base, int align)
return q;
}
-#if 0
/*******************************************************************
-reads or writes a structure.
+reads or writes an RPC_HDR structure.
********************************************************************/
- char* smb_io_(BOOL io, *, char *q, char *base, int align)
+char* smb_io_rpc_hdr(BOOL io, RPC_HDR *rpc, char *q, char *base, int align)
{
- if (== NULL) return NULL;
-
- q = align_offset(q, base, align);
-
- RW_IVAL(io, q, , 0); q += 4;
+ if (rpc == NULL) return NULL;
+
+ /* reserved should be zero: enforce it */
+ rpc->reserved = 0;
+
+ RW_CVAL(io, q, rpc->major, 0); q++;
+ RW_CVAL(io, q, rpc->minor, 0); q++;
+ RW_CVAL(io, q, rpc->pkt_type, 0); q++;
+ RW_CVAL(io, q, rpc->frag, 0); q++;
+ RW_IVAL(io, q, rpc->pack_type, 0); q += 4;
+ RW_SVAL(io, q, rpc->frag_len, 0); q += 2;
+ RW_SVAL(io, q, rpc->auth_len, 0); q += 2;
+ RW_IVAL(io, q, rpc->call_id, 0); q += 4;
+ RW_SVAL(io, q, rpc->alloc_hint, 0); q += 2;
+ RW_CVAL(io, q, rpc->context_id, 0); q++;
+ RW_CVAL(io, q, rpc->reserved, 0); q++;
return q;
}
+#if 0
/*******************************************************************
reads or writes a structure.
********************************************************************/
--
cgit
From 095edfca783a6f99eb7897d4c925ce8bc1ea0a3e Mon Sep 17 00:00:00 2001
From: Luke Leighton
Date: Sun, 5 Oct 1997 11:56:08 +0000
Subject: smb.h:
added more structures, this time for the use in the query and response
of the LSA_XXXX functions. next target: the NTLOGON mailslots (10 minutes
work).
smbparse.c:
tidying. adding some more sub-structure functions.
---
source/include/smb.h | 377 ++++++++++++++++++++++++++++++++++++++++++++++++++-
source/smbparse.c | 32 ++++-
2 files changed, 403 insertions(+), 6 deletions(-)
diff --git a/source/include/smb.h b/source/include/smb.h
index b999c136677..eb20a16cd30 100644
--- a/source/include/smb.h
+++ b/source/include/smb.h
@@ -257,10 +257,14 @@ typedef fstring string;
/* 32 bit time (sec) since 01jan1970 - cifs6.txt, section 3.5, page 30 */
-typedef uint32 UTIME;
+typedef struct time_info
+{
+ uint32 time;
+
+} UTIME;
/* 64 bit time (100usec) since ????? - cifs6.txt, section 3.5, page 30 */
-typedef struct nttime
+typedef struct nttime_info
{
uint32 low;
uint32 high;
@@ -348,10 +352,17 @@ typedef struct log_info
} DOM_LOG_INFO;
-/* DOM_CREDs - client or server credentials */
-typedef struct cred_info
+/* DOM_CHAL - challenge info */
+typedef struct chal_info
{
uint8 data[8]; /* credentials */
+
+} DOM_CHAL;
+
+/* DOM_CREDs - timestamped client or server credentials */
+typedef struct cred_info
+{
+ DOM_CHAL challenge; /* credentials */
UTIME timestamp; /* credential time-stamp */
} DOM_CRED;
@@ -437,6 +448,364 @@ typedef struct rpc_hdr_info
uint8 reserved; /* 0 - reserved */
} RPC_HDR;
+/* DOM_QUERY_5 - info class 5 LSA Query response */
+typedef struct dom_query_5_info
+{
+ uint16 uni_dom_max_len; /* domain name string length * 2 */
+ uint16 uni_dom_str_len; /* domain name string length * 2 */
+ uint32 buffer_dom_name; /* undocumented domain name string buffer pointer */
+ uint32 buffer_dom_sid; /* undocumented domain SID string buffer pointer */
+ UNISTR uni_domain_name; /* domain name (unicode string) */
+ DOM_SID dom_sid; /* domain SID */
+
+} DOM_QUERY_5;
+
+/* level 5 is same as level 3. we hope. */
+typedef DOM_QUERY_5 DOM_QUERY_3;
+
+/* LSA_POL_HND */
+typedef struct lsa_policy_info
+{
+ uint8 data[20]; /* policy handle */
+
+} LSA_POL_HND;
+
+
+/* LSA_Q_QUERY_INFO - LSA query info policy */
+typedef struct lsa_query_info
+{
+ uint16 info_class; /* info class (also a policy handle?) */
+
+} LSA_Q_QUERY_INFO;
+
+/* LSA_R_QUERY_INFO - response to LSA query info policy */
+typedef struct lsa_r_query_info
+{
+ uint32 undoc_buffer; /* undocumented buffer pointer */
+ uint16 info_class; /* info class (same as info class in request) */
+
+ union
+ {
+ DOM_QUERY_3 id3;
+ DOM_QUERY_5 id5;
+ } dom;
+
+} LSA_R_QUERY_INFO;
+
+#define MAX_REF_DOMAINS 10
+
+/* DOM_R_REF */
+typedef struct dom_ref_info
+{
+ uint32 undoc_buffer; /* undocumented buffer pointer. */
+ uint32 num_ref_doms_1; /* num referenced domains? */
+ uint32 buffer_dom_name; /* undocumented domain name buffer pointer. */
+ uint32 max_entries; /* 32 - max number of entries */
+ uint32 num_ref_doms_2; /* 4 - num referenced domains? */
+
+ UNIHDR2 hdr_dom_name; /* domain name unicode string header */
+ UNIHDR2 hdr_ref_dom[MAX_REF_DOMAINS]; /* referenced domain unicode string headers */
+
+ UNISTR uni_dom_name; /* domain name unicode string */
+ DOM_SID uni_dom_sid; /* domain SID */
+ DOM_SID uni_ref_dom[MAX_REF_DOMAINS]; /* referenced domain SIDs */
+
+} DOM_R_REF;
+
+#define MAX_LOOKUP_SIDS 10
+
+/* LSA_Q_LOOKUP_SIDS - LSA Lookup SIDs */
+typedef struct lsa_q_lookup_sids
+{
+
+ LSA_POL_HND pol_hnd; /* policy handle */
+ uint32 num_entries;
+ uint32 buffer_dom_sid; /* undocumented domain SID buffer pointer */
+ uint32 buffer_dom_name; /* undocumented domain name buffer pointer */
+ uint32 buffer_lookup_sids[MAX_LOOKUP_SIDS]; /* undocumented domain SID pointers to be looked up. */
+ DOM_SID dom_sids[MAX_LOOKUP_SIDS]; /* domain SIDs to be looked up. */
+ uint8 undoc[16]; /* completely undocumented 16 bytes */
+
+} LSA_Q_LOOKUP_SIDS;
+
+/* LSA_R_LOOKUP_SIDS - response to LSA Lookup SIDs */
+typedef struct lsa_r_lookup_sids
+{
+ DOM_R_REF dom_ref; /* domain reference info */
+
+ uint32 num_entries;
+ uint32 undoc_buffer2; /* undocumented buffer pointer */
+ uint32 num_entries2;
+
+ DOM_SID2 dom_sid[MAX_LOOKUP_SIDS]; /* domain SIDs being looked up */
+
+ uint32 num_entries3;
+
+} LSA_R_LOOKUP_SIDS;
+
+/* DOM_NAME - XXXX not sure about this structure */
+typedef struct dom_name_info
+{
+ uint32 uni_str_len;
+ uint16 buffer[MAX_UNISTRLEN];
+
+} DOM_NAME;
+
+
+#define UNKNOWN_LEN 1
+
+/* LSA_Q_LOOKUP_RIDS - LSA Lookup RIDs */
+typedef struct lsa_q_lookup_rids
+{
+
+ LSA_POL_HND pol_hnd; /* policy handle */
+ uint32 num_entries;
+ uint32 num_entries2;
+ uint32 buffer_dom_sid; /* undocumented domain SID buffer pointer */
+ uint32 buffer_dom_name; /* undocumented domain name buffer pointer */
+ DOM_NAME lookup_name[MAX_LOOKUP_SIDS]; /* names to be looked up */
+ uint8 undoc[UNKNOWN_LEN]; /* completely undocumented bytes of unknown length */
+
+} LSA_Q_LOOKUP_RIDS;
+
+/* LSA_R_LOOKUP_RIDS - response to LSA Lookup Names */
+typedef struct lsa_r_lookup_rids
+{
+
+ uint32 num_entries;
+ uint32 undoc_buffer2; /* undocumented buffer pointer */
+
+ uint32 num_entries2;
+ DOM_RID2 dom_rid[MAX_LOOKUP_SIDS]; /* domain RIDs being looked up */
+
+ uint32 num_entries3;
+
+} LSA_R_LOOKUP_RIDS;
+
+
+
+/* NEG_FLAGS */
+typedef struct lsa_neg_flags_info
+{
+ uint32 neg_flags; /* negotiated flags */
+
+} NEG_FLAGS;
+
+
+/* LSA_Q_REQ_CHAL */
+typedef struct lsa_q_req_chal_info
+{
+ uint32 undoc_buffer; /* undocumented buffer pointer */
+ UNISTR2 uni_logon_srv; /* logon server unicode string */
+ UNISTR2 uni_logon_clnt; /* logon client unicode string */
+ DOM_CHAL clnt_chal; /* client challenge */
+
+} LSA_Q_REQ_CHAL;
+
+
+/* LSA_R_REQ_CHAL */
+typedef struct lsa_r_req_chal_info
+{
+ DOM_CHAL srv_chal; /* server challenge */
+
+} LSA_R_REQ_CHAL;
+
+
+
+/* LSA_Q_AUTH_2 */
+typedef struct lsa_q_auth2_info
+{
+ DOM_LOG_INFO clnt_id; /* client identification info */
+ DOM_CHAL clnt_chal; /* client-calculated credentials */
+
+ NEG_FLAGS clnt_flgs; /* usually 0x0000 01ff */
+
+} LSA_Q_AUTH_2;
+
+
+/* LSA_R_AUTH_2 */
+typedef struct lsa_r_auth2_info
+{
+ DOM_CHAL srv_chal; /* server-calculated credentials */
+ NEG_FLAGS srv_flgs; /* usually 0x0000 01ff */
+
+} LSA_R_AUTH_2;
+
+
+/* LSA_Q_SRV_PWSET */
+typedef struct lsa_q_srv_pwset_info
+{
+ DOM_CLNT_INFO clnt_id; /* client identification/authentication info */
+ char pwd[16]; /* new password - undocumented. */
+
+} LSA_Q_SRV_PWSET;
+
+/* LSA_R_SRV_PWSET */
+typedef struct lsa_r_srv_pwset_info
+{
+ DOM_CHAL srv_chal; /* server-calculated credentials */
+
+} LSA_R_SRV_PWSET;
+
+#define LSA_MAX_GROUPS 32
+
+/* LSA_USER_INFO */
+typedef struct lsa_q_user_info
+{
+ uint32 undoc_buffer;
+
+ NTTIME logon_time; /* logon time */
+ NTTIME logoff_time; /* logoff time */
+ NTTIME kickoff_time; /* kickoff time */
+ NTTIME pass_last_set_time; /* password last set time */
+ NTTIME pass_can_change_time; /* password can change time */
+ NTTIME pass_must_change_time; /* password must change time */
+
+ UNIHDR hdr_user_name; /* username unicode string header */
+ UNIHDR hdr_full_name; /* user's full name unicode string header */
+ UNIHDR hdr_logon_script; /* logon script unicode string header */
+ UNIHDR hdr_profile_path; /* profile path unicode string header */
+ UNIHDR hdr_home_dir; /* home directory unicode string header */
+ UNIHDR hdr_dir_drive; /* home directory drive unicode string header */
+
+ uint16 logon_count; /* logon count */
+ uint16 bad_pw_count; /* bad password count */
+
+ uint32 user_id; /* User ID */
+ uint32 group_id; /* Group ID */
+ uint32 num_groups; /* num groups */
+ uint32 buffer_groups; /* undocumented buffer pointer to groups. */
+ uint32 user_flgs; /* user flags */
+
+ char sess_key[16]; /* unused user session key */
+
+ UNIHDR hdr_logon_srv; /* logon server unicode string header */
+ UNIHDR hdr_logon_dom; /* logon domain unicode string header */
+
+ uint32 buffer_dom_id; /* undocumented logon domain id pointer */
+ char padding[40]; /* unused padding bytes? */
+
+ uint32 num_sids; /* 0 - num_sids */
+ uint32 buffer_sids; /* NULL - undocumented pointer to SIDs. */
+
+ UNISTR2 uni_user_name; /* username unicode string */
+ UNISTR2 uni_full_name; /* user's full name unicode string */
+ UNISTR2 uni_logon_script; /* logon script unicode string */
+ UNISTR2 uni_profile_path; /* profile path unicode string */
+ UNISTR2 uni_home_dir; /* home directory unicode string */
+ UNISTR2 uni_dir_drive; /* home directory drive unicode string */
+
+ uint32 num_groups2; /* num groups */
+ DOM_GID gids[LSA_MAX_GROUPS]; /* group info */
+
+ UNISTR2 uni_logon_srv; /* logon server unicode string */
+ UNISTR2 uni_logon_dom; /* logon domain unicode string */
+
+ DOM_SID undoc_dom_sids[2]; /* undocumented - domain SIDs */
+ DOM_SID dom_sid; /* domain SID */
+
+} LSA_USER_INFO;
+
+
+/* LSA_Q_SAM_LOGON */
+typedef struct lsa_q_sam_logon_info
+{
+ DOM_SAM_INFO sam_id;
+
+} LSA_Q_SAM_LOGON;
+
+/* LSA_R_SAM_LOGON */
+typedef struct lsa_r_sam_logon_info
+{
+ uint32 buffer_creds; /* undocumented buffer pointer */
+ DOM_CRED srv_creds; /* server credentials. server time stamp appears to be ignored. */
+
+ uint32 buffer_user;
+ LSA_USER_INFO user;
+
+ uint32 auth_resp; /* 1 - Authoritative response; 0 - Non-Auth? */
+
+} LSA_R_SAM_LOGON;
+
+
+/* LSA_Q_SAM_LOGOFF */
+typedef struct lsa_q_sam_logoff_info
+{
+ DOM_SAM_INFO sam_id;
+
+} LSA_Q_SAM_LOGOFF;
+
+/* LSA_R_SAM_LOGOFF */
+typedef struct lsa_r_sam_logoff_info
+{
+ uint32 buffer_creds; /* undocumented buffer pointer */
+ DOM_CRED srv_creds; /* server credentials. server time stamp appears to be ignored. */
+
+} LSA_R_SAM_LOGOFF;
+
+/*
+
+Yet to be turned into structures:
+
+6) \\MAILSLOT\NET\NTLOGON
+-------------------------
+
+6.1) Query for PDC
+------------------
+
+Request:
+
+ uint16 0x0007 - Query for PDC
+ STR machine name
+ STR response mailslot
+ uint8[] padding to 2-byte align with start of mailslot.
+ UNISTR machine name
+ uint32 NTversion
+ uint16 LMNTtoken
+ uint16 LM20token
+
+Response:
+
+ uint16 0x000A - Respose to Query for PDC
+ STR machine name (in uppercase)
+ uint8[] padding to 2-byte align with start of mailslot.
+ UNISTR machine name
+ UNISTR domain name
+ uint32 NTversion (same as received in request)
+ uint16 LMNTtoken (same as received in request)
+ uint16 LM20token (same as received in request)
+
+
+6.2) SAM Logon
+--------------
+
+Request:
+
+ uint16 0x0012 - SAM Logon
+ uint16 request count
+ UNISTR machine name
+ UNISTR user name
+ STR response mailslot
+ uint32 alloweable account
+ uint32 domain SID size
+ char[sid_size] domain SID, of sid_size bytes.
+ uint8[] ???? padding to 4? 2? -byte align with start of mailslot.
+ uint32 NTversion
+ uint16 LMNTtoken
+ uint16 LM20token
+
+Response:
+
+ uint16 0x0013 - Response to SAM Logon
+ UNISTR machine name
+ UNISTR user name - workstation trust account
+ UNISTR domain name
+ uint32 NTversion
+ uint16 LMNTtoken
+ uint16 LM20token
+
+*/
+
struct smb_passwd {
int smb_userid;
diff --git a/source/smbparse.c b/source/smbparse.c
index d39f18de5f4..869aab21c1e 100644
--- a/source/smbparse.c
+++ b/source/smbparse.c
@@ -24,6 +24,20 @@
extern int DEBUGLEVEL;
+/*******************************************************************
+reads or writes a UTIME type.
+********************************************************************/
+char* smb_io_utime(BOOL io, UTIME *t, char *q, char *base, int align)
+{
+ if (t == NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ RW_IVAL (io, q, t->time, 0); q += 4;
+
+ return q;
+}
+
/*******************************************************************
reads or writes an NTTIME structure.
********************************************************************/
@@ -222,6 +236,20 @@ char* smb_io_log_info(BOOL io, DOM_LOG_INFO *log, char *q, char *base, int align
return q;
}
+/*******************************************************************
+reads or writes a DOM_CHAL structure.
+********************************************************************/
+char* smb_io_chal(BOOL io, DOM_CHAL *chal, char *q, char *base, int align)
+{
+ if (chal == NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ RW_PCVAL(io, q, chal->data, 8); q += 8;
+
+ return q;
+}
+
/*******************************************************************
reads or writes a DOM_CRED structure.
********************************************************************/
@@ -231,8 +259,8 @@ char* smb_io_cred(BOOL io, DOM_CRED *cred, char *q, char *base, int align)
q = align_offset(q, base, align);
- RW_PCVAL(io, q, cred->data, 8); q += 8;
- RW_IVAL (io, q, cred->timestamp, 0); q += 4;
+ q = smb_io_chal (io, &(cred->challenge), q, base, align);
+ q = smb_io_utime(io, &(cred->timestamp), q, base, align);
return q;
}
--
cgit
From 369f7d41d6ff6d2b9b8c1e0cac99d0f0d03410b0 Mon Sep 17 00:00:00 2001
From: Luke Leighton
Date: Sun, 5 Oct 1997 12:39:51 +0000
Subject: processes LSA queries and responses to/from RPC data stream into
structures.
---
source/lsaparse.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 88 insertions(+)
create mode 100644 source/lsaparse.c
diff --git a/source/lsaparse.c b/source/lsaparse.c
new file mode 100644
index 00000000000..52c9335cd03
--- /dev/null
+++ b/source/lsaparse.c
@@ -0,0 +1,88 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Samba utility functions
+ Copyright (C) Luke Leighton 1996 - 1997
+
+ 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"
+
+extern int DEBUGLEVEL;
+
+
+/*******************************************************************
+reads or writes an LSA_Q_QUERY_INFO structure.
+********************************************************************/
+char* lsa_io_q_query(BOOL io, LSA_Q_QUERY_INFO *q_q, char *q, char *base, int align)
+{
+ if (q_q == NULL) return NULL;
+
+ RW_SVAL(io, q, q_q->info_class, 0); q += 2;
+
+ return q;
+}
+
+/*******************************************************************
+reads or writes an LSA_Q_QUERY_INFO structure.
+********************************************************************/
+char* lsa_io_r_query(BOOL io, LSA_R_QUERY_INFO *r_q, char *q, char *base, int align)
+{
+ if (r_q == NULL) return NULL;
+
+ RW_IVAL(io, q, r_q->undoc_buffer, 0); q += 4;
+
+ if (r_q->undoc_buffer != 0)
+ {
+ RW_SVAL(io, q, r_q->info_class, 0); q += 2;
+
+ switch (r_q->info_class)
+ {
+ case 3:
+ {
+ q = smb_io_dom_query_3(io, &(r_q->dom.id3), q, base, align);
+ break;
+ }
+ case 5:
+ {
+ q = smb_io_dom_query_5(io, &(r_q->dom.id3), q, base, align);
+ break;
+ }
+ default:
+ {
+ /* PANIC! */
+ break;
+ }
+ }
+ }
+ return q;
+}
+
+#if 0
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+ char* smb_io_(BOOL io, *, char *q, char *base, int align)
+{
+ if (== NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ RW_IVAL(io, q, , 0); q += 4;
+
+ return q;
+}
+#endif
--
cgit
From 2f722fe289051558dbe77aeb0a830bb3ded10a83 Mon Sep 17 00:00:00 2001
From: Luke Leighton
Date: Sun, 5 Oct 1997 14:17:53 +0000
Subject: updating lsa and smb parsing routines and structures.
---
source/include/proto.h | 32 +++++++++++++++++
source/include/smb.h | 23 +++++++++----
source/lsaparse.c | 15 +++++++-
source/smbparse.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++++-
4 files changed, 155 insertions(+), 8 deletions(-)
diff --git a/source/include/proto.h b/source/include/proto.h
index 4ec4a42f2aa..705b08b633c 100644
--- a/source/include/proto.h
+++ b/source/include/proto.h
@@ -310,6 +310,11 @@ void del_share_mode(share_lock_token token, int fnum);
BOOL set_share_mode(share_lock_token token,int fnum, uint16 port, uint16 op_type);
BOOL remove_share_oplock(int fnum, share_lock_token token);
+/*The following definitions come from lsaparse.c */
+
+char* lsa_io_q_query(BOOL io, LSA_Q_QUERY_INFO *q_q, char *q, char *base, int align);
+char* lsa_io_r_query(BOOL io, LSA_R_QUERY_INFO *r_q, char *q, char *base, int align);
+
/*The following definitions come from mangle.c */
int str_checksum(char *s);
@@ -772,6 +777,33 @@ void SMBencrypt(uchar *passwd, uchar *c8, uchar *p24);
void E_md4hash(uchar *passwd, uchar *p16);
void SMBNTencrypt(uchar *passwd, uchar *c8, uchar *p24);
+/*The following definitions come from smbparse.c */
+
+char* smb_io_utime(BOOL io, UTIME *t, char *q, char *base, int align);
+char* smb_io_time(BOOL io, NTTIME *nttime, char *q, char *base, int align);
+char* smb_io_dom_sid(BOOL io, DOM_SID *sid, char *q, char *base, int align);
+char* smb_io_unihdr(BOOL io, UNIHDR *hdr, char *q, char *base, int align);
+char* smb_io_unihdr2(BOOL io, UNIHDR2 *hdr2, char *q, char *base, int align);
+char* smb_io_unistr(BOOL io, UNISTR *uni, char *q, char *base, int align);
+char* smb_io_unistr2(BOOL io, UNISTR2 *uni2, char *q, char *base, int align);
+char* smb_io_dom_sid2(BOOL io, DOM_SID2 *sid2, char *q, char *base, int align);
+char* smb_io_dom_rid2(BOOL io, DOM_RID2 *rid2, char *q, char *base, int align);
+char* smb_io_log_info(BOOL io, DOM_LOG_INFO *log, char *q, char *base, int align);
+char* smb_io_chal(BOOL io, DOM_CHAL *chal, char *q, char *base, int align);
+char* smb_io_cred(BOOL io, DOM_CRED *cred, char *q, char *base, int align);
+char* smb_io_clnt_info(BOOL io, DOM_CLNT_INFO *clnt, char *q, char *base, int align);
+char* smb_io_logon_id(BOOL io, DOM_LOGON_ID *log, char *q, char *base, int align);
+char* smb_io_rc4_owf(BOOL io, RC4_OWF *hash, char *q, char *base, int align);
+char* smb_io_id_info1(BOOL io, DOM_ID_INFO_1 *id, char *q, char *base, int align);
+char* smb_io_sam_info(BOOL io, DOM_SAM_INFO *sam, char *q, char *base, int align);
+char* smb_io_gid(BOOL io, DOM_GID *gid, char *q, char *base, int align);
+char* smb_io_rpc_hdr(BOOL io, RPC_HDR *rpc, char *q, char *base, int align);
+char* smb_io_pol_hnd(BOOL io, LSA_POL_HND *pol, char *q, char *base, int align);
+char* smb_io_dom_query_3(BOOL io, DOM_QUERY_3 *d_q, char *q, char *base, int align);
+char* smb_io_dom_query_5(BOOL io, DOM_QUERY_3 *d_q, char *q, char *base, int align);
+char* smb_io_dom_query(BOOL io, DOM_QUERY *d_q, char *q, char *base, int align);
+char* smb_io_dom_r_ref(BOOL io, DOM_R_REF *r_r, char *q, char *base, int align);
+
/*The following definitions come from smbpass.c */
int pw_file_lock(char *name, int type, int secs);
diff --git a/source/include/smb.h b/source/include/smb.h
index eb20a16cd30..a3a6d326e03 100644
--- a/source/include/smb.h
+++ b/source/include/smb.h
@@ -331,6 +331,16 @@ typedef struct domsid2_info
} DOM_SID2;
+/* DOM_SID3 - domain SID structure - SIDs stored in unicode */
+typedef struct domsid3_info
+{
+ UNISTR str; /* domain SID unicode string */
+ uint32 undoc; /* value is 0 */
+ uint32 type1; /* value is 1 */
+ uint32 type2; /* value is 5 or 3 */
+
+} DOM_SID3;
+
/* DOM_RID2 - domain RID structure */
typedef struct domrid2_info
{
@@ -446,10 +456,11 @@ typedef struct rpc_hdr_info
uint16 context_id; /* 0 - presentation context identifier */
uint8 cancel_count; /* 0 - cancel count */
uint8 reserved; /* 0 - reserved */
+
} RPC_HDR;
-/* DOM_QUERY_5 - info class 5 LSA Query response */
-typedef struct dom_query_5_info
+/* DOM_QUERY - info class 3 and 5 LSA Query response */
+typedef struct dom_query_info
{
uint16 uni_dom_max_len; /* domain name string length * 2 */
uint16 uni_dom_str_len; /* domain name string length * 2 */
@@ -458,10 +469,11 @@ typedef struct dom_query_5_info
UNISTR uni_domain_name; /* domain name (unicode string) */
DOM_SID dom_sid; /* domain SID */
-} DOM_QUERY_5;
+} DOM_QUERY;
/* level 5 is same as level 3. we hope. */
-typedef DOM_QUERY_5 DOM_QUERY_3;
+typedef DOM_QUERY DOM_QUERY_3;
+typedef DOM_QUERY DOM_QUERY_5;
/* LSA_POL_HND */
typedef struct lsa_policy_info
@@ -507,8 +519,7 @@ typedef struct dom_ref_info
UNIHDR2 hdr_ref_dom[MAX_REF_DOMAINS]; /* referenced domain unicode string headers */
UNISTR uni_dom_name; /* domain name unicode string */
- DOM_SID uni_dom_sid; /* domain SID */
- DOM_SID uni_ref_dom[MAX_REF_DOMAINS]; /* referenced domain SIDs */
+ DOM_SID ref_dom[MAX_REF_DOMAINS]; /* referenced domain SIDs */
} DOM_R_REF;
diff --git a/source/lsaparse.c b/source/lsaparse.c
index 52c9335cd03..0e38c8a6670 100644
--- a/source/lsaparse.c
+++ b/source/lsaparse.c
@@ -75,7 +75,20 @@ char* lsa_io_r_query(BOOL io, LSA_R_QUERY_INFO *r_q, char *q, char *base, int al
/*******************************************************************
reads or writes a structure.
********************************************************************/
- char* smb_io_(BOOL io, *, char *q, char *base, int align)
+ char* lsa_io_(BOOL io, *, char *q, char *base, int align)
+{
+ if (== NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ RW_IVAL(io, q, , 0); q += 4;
+
+ return q;
+}
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+ char* lsa_io_(BOOL io, *, char *q, char *base, int align)
{
if (== NULL) return NULL;
diff --git a/source/smbparse.c b/source/smbparse.c
index 869aab21c1e..e109f09a6f6 100644
--- a/source/smbparse.c
+++ b/source/smbparse.c
@@ -56,7 +56,7 @@ char* smb_io_time(BOOL io, NTTIME *nttime, char *q, char *base, int align)
/*******************************************************************
reads or writes a DOM_SID structure.
********************************************************************/
-char* smb_io_sid(BOOL io, DOM_SID *sid, char *q, char *base, int align)
+char* smb_io_dom_sid(BOOL io, DOM_SID *sid, char *q, char *base, int align)
{
int i;
@@ -407,6 +407,97 @@ char* smb_io_rpc_hdr(BOOL io, RPC_HDR *rpc, char *q, char *base, int align)
return q;
}
+/*******************************************************************
+reads or writes an LSA_POL_HND structure.
+********************************************************************/
+char* smb_io_pol_hnd(BOOL io, LSA_POL_HND *pol, char *q, char *base, int align)
+{
+ if (pol == NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ RW_PCVAL(io, q, pol->data, 20); q += 20;
+
+ return q;
+}
+
+/*******************************************************************
+reads or writes a dom query structure.
+********************************************************************/
+char* smb_io_dom_query_3(BOOL io, DOM_QUERY_3 *d_q, char *q, char *base, int align)
+{
+ return smb_io_dom_query(io, d_q, q, base, align);
+}
+
+/*******************************************************************
+reads or writes a dom query structure.
+********************************************************************/
+char* smb_io_dom_query_5(BOOL io, DOM_QUERY_3 *d_q, char *q, char *base, int align)
+{
+ return smb_io_dom_query(io, d_q, q, base, align);
+}
+
+/*******************************************************************
+reads or writes a dom query structure.
+********************************************************************/
+char* smb_io_dom_query(BOOL io, DOM_QUERY *d_q, char *q, char *base, int align)
+{
+ if (d_q == NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+
+ RW_SVAL(io, q, d_q->uni_dom_max_len, 0); q += 2; /* domain name string length * 2 */
+ RW_SVAL(io, q, d_q->uni_dom_str_len, 0); q += 2; /* domain name string length * 2 */
+
+ RW_IVAL(io, q, d_q->buffer_dom_name, 0); q += 4; /* undocumented domain name string buffer pointer */
+ RW_IVAL(io, q, d_q->buffer_dom_sid , 0); q += 4; /* undocumented domain SID string buffer pointer */
+
+ if (d_q->buffer_dom_name != 0)
+ {
+ q = smb_io_unistr(io, &(d_q->uni_domain_name), q, base, align); /* domain name (unicode string) */
+ }
+ if (d_q->buffer_dom_sid != 0)
+ {
+ q = smb_io_dom_sid(io, &(d_q->dom_sid), q, base, align); /* domain SID */
+ }
+
+ return q;
+}
+
+/*******************************************************************
+reads or writes a DOM_R_REF structure.
+********************************************************************/
+char* smb_io_dom_r_ref(BOOL io, DOM_R_REF *r_r, char *q, char *base, int align)
+{
+ int i;
+
+ if (r_r == NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ RW_IVAL(io, q, r_r->undoc_buffer, 0); q += 4; /* undocumented buffer pointer. */
+ RW_IVAL(io, q, r_r->num_ref_doms_1, 0); q += 4; /* num referenced domains? */
+ RW_IVAL(io, q, r_r->buffer_dom_name, 0); q += 4; /* undocumented domain name buffer pointer. */
+ RW_IVAL(io, q, r_r->max_entries, 0); q += 4; /* 32 - max number of entries */
+ RW_IVAL(io, q, r_r->num_ref_doms_2, 0); q += 4; /* 4 - num referenced domains? */
+
+ q = smb_io_unihdr2(io, &(r_r->hdr_dom_name), q, base, align); /* domain name unicode string header */
+
+ for (i = 0; i < r_r->num_ref_doms_1-1; i++)
+ {
+ q = smb_io_unihdr2(io, &(r_r->hdr_ref_dom[i]), q, base, align);
+ }
+
+ q = smb_io_unistr(io, &(r_r->uni_dom_name), q, base, align); /* domain name unicode string */
+
+ for (i = 0; i < r_r->num_ref_doms_2; i++)
+ {
+ q = smb_io_dom_sid(io, &(r_r->ref_dom[i]), q, base, align); /* referenced domain SIDs */
+ }
+ return q;
+}
+
#if 0
/*******************************************************************
reads or writes a structure.
--
cgit
From a1c718728c46ebf8916af8985b4dae4d099f4ec2 Mon Sep 17 00:00:00 2001
From: Luke Leighton
Date: Mon, 6 Oct 1997 13:30:54 +0000
Subject: Makefile: added lsaparse.c and smbparse.c
lsaparse.c, smbparse.c, smb.h: more functions / structures. proto.h:
the usual.
---
source/include/proto.h | 13 ++
source/include/smb.h | 9 +-
source/lsaparse.c | 387 ++++++++++++++++++++++++++++++++++++++++++++++++-
source/smbparse.c | 37 ++++-
4 files changed, 442 insertions(+), 4 deletions(-)
diff --git a/source/include/proto.h b/source/include/proto.h
index 705b08b633c..a6250ca56c8 100644
--- a/source/include/proto.h
+++ b/source/include/proto.h
@@ -314,6 +314,17 @@ BOOL remove_share_oplock(int fnum, share_lock_token token);
char* lsa_io_q_query(BOOL io, LSA_Q_QUERY_INFO *q_q, char *q, char *base, int align);
char* lsa_io_r_query(BOOL io, LSA_R_QUERY_INFO *r_q, char *q, char *base, int align);
+char* lsa_io_q_lookup_sids(BOOL io, LSA_Q_LOOKUP_SIDS *q_s, char *q, char *base, int align);
+char* lsa_io_r_lookup_sids(BOOL io, LSA_R_LOOKUP_SIDS *r_s, char *q, char *base, int align);
+char* lsa_io_q_lookup_rids(BOOL io, LSA_Q_LOOKUP_RIDS *q_r, char *q, char *base, int align);
+char* lsa_io_r_lookup_rids(BOOL io, LSA_R_LOOKUP_RIDS *r_r, char *q, char *base, int align);
+char* lsa_io_q_req_chal(BOOL io, LSA_Q_REQ_CHAL *q_c, char *q, char *base, int align);
+char* lsa_io_r_req_chal(BOOL io, LSA_R_REQ_CHAL *r_c, char *q, char *base, int align);
+char* lsa_io_q_auth2(BOOL io, LSA_Q_AUTH_2 *q_a, char *q, char *base, int align);
+char* lsa_io_r_auth_2(BOOL io, LSA_R_AUTH_2 *r_a, char *q, char *base, int align);
+char* lsa_io_q_srv_pwset(BOOL io, LSA_Q_SRV_PWSET *q_s, char *q, char *base, int align);
+char* lsa_io_r_srv_pwset(BOOL io, LSA_R_SRV_PWSET *r_s, char *q, char *base, int align);
+char* lsa_io_user_info(BOOL io, LSA_USER_INFO *usr, char *q, char *base, int align);
/*The following definitions come from mangle.c */
@@ -803,6 +814,8 @@ char* smb_io_dom_query_3(BOOL io, DOM_QUERY_3 *d_q, char *q, char *base, int ali
char* smb_io_dom_query_5(BOOL io, DOM_QUERY_3 *d_q, char *q, char *base, int align);
char* smb_io_dom_query(BOOL io, DOM_QUERY *d_q, char *q, char *base, int align);
char* smb_io_dom_r_ref(BOOL io, DOM_R_REF *r_r, char *q, char *base, int align);
+char* smb_io_dom_name(BOOL io, DOM_NAME *name, char *q, char *base, int align);
+char* smb_io_neg_flags(BOOL io, NEG_FLAGS *neg, char *q, char *base, int align);
/*The following definitions come from smbpass.c */
diff --git a/source/include/smb.h b/source/include/smb.h
index a3a6d326e03..280147b41f9 100644
--- a/source/include/smb.h
+++ b/source/include/smb.h
@@ -545,7 +545,7 @@ typedef struct lsa_r_lookup_sids
DOM_R_REF dom_ref; /* domain reference info */
uint32 num_entries;
- uint32 undoc_buffer2; /* undocumented buffer pointer */
+ uint32 undoc_buffer; /* undocumented buffer pointer */
uint32 num_entries2;
DOM_SID2 dom_sid[MAX_LOOKUP_SIDS]; /* domain SIDs being looked up */
@@ -558,7 +558,11 @@ typedef struct lsa_r_lookup_sids
typedef struct dom_name_info
{
uint32 uni_str_len;
+#if 1 /* don't know if buffer is null-terminated */
+ UNISTR buffer;
+#else /* or length indicated by uni_str_len member */
uint16 buffer[MAX_UNISTRLEN];
+#endif
} DOM_NAME;
@@ -582,9 +586,10 @@ typedef struct lsa_q_lookup_rids
/* LSA_R_LOOKUP_RIDS - response to LSA Lookup Names */
typedef struct lsa_r_lookup_rids
{
+ DOM_R_REF dom_ref; /* domain reference info */
uint32 num_entries;
- uint32 undoc_buffer2; /* undocumented buffer pointer */
+ uint32 undoc_buffer; /* undocumented buffer pointer */
uint32 num_entries2;
DOM_RID2 dom_rid[MAX_LOOKUP_SIDS]; /* domain RIDs being looked up */
diff --git a/source/lsaparse.c b/source/lsaparse.c
index 0e38c8a6670..68884833f4c 100644
--- a/source/lsaparse.c
+++ b/source/lsaparse.c
@@ -2,7 +2,7 @@
Unix SMB/Netbios implementation.
Version 1.9.
Samba utility functions
- Copyright (C) Luke Leighton 1996 - 1997
+ Copyright (C) Luke Leighton 1996 - 1997 Paul Ashton 1997
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
@@ -71,6 +71,285 @@ char* lsa_io_r_query(BOOL io, LSA_R_QUERY_INFO *r_q, char *q, char *base, int al
return q;
}
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+char* lsa_io_q_lookup_sids(BOOL io, LSA_Q_LOOKUP_SIDS *q_s, char *q, char *base, int align)
+{
+ int i;
+
+ if (q_s == NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ q = smb_io_pol_hnd(io, &(q_s->pol_hnd), q, base, align); /* policy handle */
+
+ RW_IVAL(io, q, q_s->num_entries, 0); q += 4;
+ RW_IVAL(io, q, q_s->buffer_dom_sid, 0); q += 4; /* undocumented domain SID buffer pointer */
+ RW_IVAL(io, q, q_s->buffer_dom_name, 0); q += 4; /* undocumented domain name buffer pointer */
+
+ for (i = 0; i < q_s->num_entries; i++)
+ {
+ RW_IVAL(io, q, q_s->buffer_lookup_sids[i], 0); q += 4; /* undocumented domain SID pointers to be looked up. */
+ }
+
+ for (i = 0; i < q_s->num_entries; i++)
+ {
+ q = smb_io_dom_sid(io, &(q_s->dom_sids[i]), q, base, align); /* domain SIDs to be looked up. */
+ }
+
+ RW_PCVAL(io, q, q_s->undoc, 16); q += 16; /* completely undocumented 16 bytes */
+
+ return q;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+char* lsa_io_r_lookup_sids(BOOL io, LSA_R_LOOKUP_SIDS *r_s, char *q, char *base, int align)
+{
+ int i;
+
+ if (r_s == NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ q = smb_io_dom_r_ref(io, &(r_s->dom_ref), q, base, align); /* domain reference info */
+
+ RW_IVAL(io, q, r_s->num_entries, 0); q += 4;
+ RW_IVAL(io, q, r_s->undoc_buffer, 0); q += 4;
+ RW_IVAL(io, q, r_s->num_entries2, 0); q += 4;
+
+ for (i = 0; i < r_s->num_entries2; i++)
+ {
+ q = smb_io_dom_sid2(io, &(r_s->dom_sid[i]), q, base, align); /* domain SIDs being looked up */
+ }
+
+ RW_IVAL(io, q, r_s->num_entries3, 0); q += 4;
+
+ return q;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+char* lsa_io_q_lookup_rids(BOOL io, LSA_Q_LOOKUP_RIDS *q_r, char *q, char *base, int align)
+{
+ int i;
+
+ if (q_r == NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ q = smb_io_pol_hnd(io, &(q_r->pol_hnd), q, base, align); /* policy handle */
+
+ RW_IVAL(io, q, q_r->num_entries, 0); q += 4;
+ RW_IVAL(io, q, q_r->num_entries2, 0); q += 4;
+ RW_IVAL(io, q, q_r->buffer_dom_sid, 0); q += 4; /* undocumented domain SID buffer pointer */
+ RW_IVAL(io, q, q_r->buffer_dom_name, 0); q += 4; /* undocumented domain name buffer pointer */
+
+ for (i = 0; i < q_r->num_entries; i++)
+ {
+ q = smb_io_dom_name(io, &(q_r->lookup_name[i]), q, base, 0); /* names to be looked up */
+ }
+
+ RW_PCVAL(io, q, q_r->undoc, UNKNOWN_LEN); q += UNKNOWN_LEN; /* completely undocumented bytes of unknown length */
+
+ return q;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+char* lsa_io_r_lookup_rids(BOOL io, LSA_R_LOOKUP_RIDS *r_r, char *q, char *base, int align)
+{
+ int i;
+
+ if (r_r == NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ q = smb_io_dom_r_ref(io, &(r_r->dom_ref), q, base, align); /* domain reference info */
+
+ RW_IVAL(io, q, r_r->num_entries, 0); q += 4;
+ RW_IVAL(io, q, r_r->undoc_buffer, 0); q += 4;
+ RW_IVAL(io, q, r_r->num_entries2, 0); q += 4;
+
+ for (i = 0; i < r_r->num_entries2; i++)
+ {
+ q = smb_io_dom_rid2(io, &(r_r->dom_rid[i]), q, base, align); /* domain RIDs being looked up */
+ }
+
+ RW_IVAL(io, q, r_r->num_entries3, 0); q += 4;
+
+ return q;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+char* lsa_io_q_req_chal(BOOL io, LSA_Q_REQ_CHAL *q_c, char *q, char *base, int align)
+{
+ if (q_c == NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ q = smb_io_unistr2(io, &(q_c->uni_logon_srv), q, base, align); /* logon server unicode string */
+ q = smb_io_unistr2(io, &(q_c->uni_logon_clnt), q, base, align); /* logon client unicode string */
+ q = smb_io_chal(io, &(q_c->clnt_chal), q, base, align); /* client challenge */
+
+ return q;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+char* lsa_io_r_req_chal(BOOL io, LSA_R_REQ_CHAL *r_c, char *q, char *base, int align)
+{
+ if (r_c == NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ q = smb_io_chal(io, &(r_c->srv_chal), q, base, align); /* server challenge */
+
+ return q;
+}
+
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+char* lsa_io_q_auth2(BOOL io, LSA_Q_AUTH_2 *q_a, char *q, char *base, int align)
+{
+ if (q_a == NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ q = smb_io_log_info (io, &(q_a->clnt_id), q, base, align); /* client identification info */
+ q = smb_io_chal (io, &(q_a->clnt_chal), q, base, align); /* client-calculated credentials */
+ q = smb_io_neg_flags(io, &(q_a->clnt_flgs), q, base, align);
+
+ return q;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+char* lsa_io_r_auth_2(BOOL io, LSA_R_AUTH_2 *r_a, char *q, char *base, int align)
+{
+ if (r_a == NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ q = smb_io_chal (io, &(r_a->srv_chal), q, base, align); /* server challenge */
+ q = smb_io_neg_flags(io, &(r_a->srv_flgs), q, base, align);
+
+ return q;
+}
+
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+char* lsa_io_q_srv_pwset(BOOL io, LSA_Q_SRV_PWSET *q_s, char *q, char *base, int align)
+{
+ if (q_s == NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ q = smb_io_clnt_info(io, &(q_s->clnt_id), q, base, align); /* client identification/authentication info */
+ RW_PCVAL(io, q, q_s->pwd, 16); q += 16; /* new password - undocumented */
+
+ return q;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+char* lsa_io_r_srv_pwset(BOOL io, LSA_R_SRV_PWSET *r_s, char *q, char *base, int align)
+{
+ if (r_s == NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ q = smb_io_chal(io, &(r_s->srv_chal), q, base, align); /* server challenge */
+
+ return q;
+}
+
+/* LSA_USER_INFO */
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+char* lsa_io_user_info(BOOL io, LSA_USER_INFO *usr, char *q, char *base, int align)
+{
+ int i;
+
+ if (usr == NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ RW_IVAL(io, q, usr->undoc_buffer, 0); q += 4;
+
+ q = smb_io_time(io, &(usr->logon_time) , q, base, align); /* logon time */
+ q = smb_io_time(io, &(usr->logoff_time) , q, base, align); /* logoff time */
+ q = smb_io_time(io, &(usr->kickoff_time) , q, base, align); /* kickoff time */
+ q = smb_io_time(io, &(usr->pass_last_set_time) , q, base, align); /* password last set time */
+ q = smb_io_time(io, &(usr->pass_can_change_time) , q, base, align); /* password can change time */
+ q = smb_io_time(io, &(usr->pass_must_change_time), q, base, align); /* password must change time */
+
+ q = smb_io_unihdr(io, &(usr->hdr_user_name) , q, base, align); /* username unicode string header */
+ q = smb_io_unihdr(io, &(usr->hdr_full_name) , q, base, align); /* user's full name unicode string header */
+ q = smb_io_unihdr(io, &(usr->hdr_logon_script), q, base, align); /* logon script unicode string header */
+ q = smb_io_unihdr(io, &(usr->hdr_profile_path), q, base, align); /* profile path unicode string header */
+ q = smb_io_unihdr(io, &(usr->hdr_home_dir) , q, base, align); /* home directory unicode string header */
+ q = smb_io_unihdr(io, &(usr->hdr_dir_drive) , q, base, align); /* home directory drive unicode string header */
+
+ RW_SVAL(io, q, usr->logon_count , 0); q += 2; /* logon count */
+ RW_SVAL(io, q, usr->bad_pw_count, 0); q += 2; /* bad password count */
+
+ RW_IVAL(io, q, usr->user_id , 0); q += 4; /* User ID */
+ RW_IVAL(io, q, usr->group_id , 0); q += 4; /* Group ID */
+ RW_IVAL(io, q, usr->num_groups , 0); q += 4; /* num groups */
+ RW_IVAL(io, q, usr->buffer_groups, 0); q += 4; /* undocumented buffer pointer to groups. */
+ RW_IVAL(io, q, usr->user_flgs , 0); q += 4; /* user flags */
+
+ RW_PCVAL(io, q, usr->sess_key, 16); q += 16; /* unused user session key */
+
+ q = smb_io_unihdr(io, &(usr->hdr_logon_srv), q, base, align); /* logon server unicode string header */
+ q = smb_io_unihdr(io, &(usr->hdr_logon_dom), q, base, align); /* logon domain unicode string header */
+
+ RW_IVAL(io, q, usr->buffer_dom_id, 0); q += 4; /* undocumented logon domain id pointer */
+ RW_PCVAL(io, q, usr->padding, 40); q += 40; /* unused padding bytes? */
+
+ RW_IVAL(io, q, usr->num_sids, 0); q += 4; /* 0 - num_sids */
+ RW_IVAL(io, q, usr->buffer_sids, 0); q += 4; /* NULL - undocumented pointer to SIDs. */
+
+ q = smb_io_unistr2(io, &(usr->uni_user_name) , q, base, align); /* username unicode string */
+ q = smb_io_unistr2(io, &(usr->uni_full_name) , q, base, align); /* user's full name unicode string */
+ q = smb_io_unistr2(io, &(usr->uni_logon_script), q, base, align); /* logon script unicode string */
+ q = smb_io_unistr2(io, &(usr->uni_profile_path), q, base, align); /* profile path unicode string */
+ q = smb_io_unistr2(io, &(usr->uni_home_dir) , q, base, align); /* home directory unicode string */
+ q = smb_io_unistr2(io, &(usr->uni_dir_drive) , q, base, align); /* home directory drive unicode string */
+
+ RW_IVAL(io, q, usr->num_groups2, 0); q += 4; /* num groups */
+ for (i = 0; i < usr->num_groups2; i++)
+ {
+ q = smb_io_gid(io, &(usr->gids[i]), q, base, align); /* group info */
+ }
+
+ q = smb_io_unistr2(io, &( usr->uni_logon_srv), q, base, align); /* logon server unicode string */
+ q = smb_io_unistr2(io, &( usr->uni_logon_dom), q, base, align); /* logon domain unicode string */
+
+ q = smb_io_dom_sid(io, &(usr->undoc_dom_sids[0]), q, base, align); /* undocumented - domain SIDs */
+ q = smb_io_dom_sid(io, &(usr->undoc_dom_sids[1]), q, base, align); /* undocumented - domain SIDs */
+ q = smb_io_dom_sid(io, &(usr->dom_sid), q, base, align); /* domain SID */
+
+ return q;
+}
+
+
#if 0
/*******************************************************************
reads or writes a structure.
@@ -85,6 +364,112 @@ reads or writes a structure.
return q;
}
+#endif
+
+
+#if 0 /* to be done... */
+
+
+#define LSA_MAX_GROUPS 32
+
+/* LSA_USER_INFO */
+typedef struct lsa_q_user_info
+{
+ uint32 undoc_buffer;
+
+ NTTIME logon_time; /* logon time */
+ NTTIME logoff_time; /* logoff time */
+ NTTIME kickoff_time; /* kickoff time */
+ NTTIME pass_last_set_time; /* password last set time */
+ NTTIME pass_can_change_time; /* password can change time */
+ NTTIME pass_must_change_time; /* password must change time */
+
+ UNIHDR hdr_user_name; /* username unicode string header */
+ UNIHDR hdr_full_name; /* user's full name unicode string header */
+ UNIHDR hdr_logon_script; /* logon script unicode string header */
+ UNIHDR hdr_profile_path; /* profile path unicode string header */
+ UNIHDR hdr_home_dir; /* home directory unicode string header */
+ UNIHDR hdr_dir_drive; /* home directory drive unicode string header */
+
+ uint16 logon_count; /* logon count */
+ uint16 bad_pw_count; /* bad password count */
+
+ uint32 user_id; /* User ID */
+ uint32 group_id; /* Group ID */
+ uint32 num_groups; /* num groups */
+ uint32 buffer_groups; /* undocumented buffer pointer to groups. */
+ uint32 user_flgs; /* user flags */
+
+ char sess_key[16]; /* unused user session key */
+
+ UNIHDR hdr_logon_srv; /* logon server unicode string header */
+ UNIHDR hdr_logon_dom; /* logon domain unicode string header */
+
+ uint32 buffer_dom_id; /* undocumented logon domain id pointer */
+ char padding[40]; /* unused padding bytes? */
+
+ uint32 num_sids; /* 0 - num_sids */
+ uint32 buffer_sids; /* NULL - undocumented pointer to SIDs. */
+
+ UNISTR2 uni_user_name; /* username unicode string */
+ UNISTR2 uni_full_name; /* user's full name unicode string */
+ UNISTR2 uni_logon_script; /* logon script unicode string */
+ UNISTR2 uni_profile_path; /* profile path unicode string */
+ UNISTR2 uni_home_dir; /* home directory unicode string */
+ UNISTR2 uni_dir_drive; /* home directory drive unicode string */
+
+ uint32 num_groups2; /* num groups */
+ DOM_GID gids[LSA_MAX_GROUPS]; /* group info */
+
+ UNISTR2 uni_logon_srv; /* logon server unicode string */
+ UNISTR2 uni_logon_dom; /* logon domain unicode string */
+
+ DOM_SID undoc_dom_sids[2]; /* undocumented - domain SIDs */
+ DOM_SID dom_sid; /* domain SID */
+
+} LSA_USER_INFO;
+
+
+/* LSA_Q_SAM_LOGON */
+typedef struct lsa_q_sam_logon_info
+{
+ DOM_SAM_INFO sam_id;
+
+} LSA_Q_SAM_LOGON;
+
+/* LSA_R_SAM_LOGON */
+typedef struct lsa_r_sam_logon_info
+{
+ uint32 buffer_creds; /* undocumented buffer pointer */
+ DOM_CRED srv_creds; /* server credentials. server time stamp appears to be ignored. */
+
+ uint32 buffer_user;
+ LSA_USER_INFO user;
+
+ uint32 auth_resp; /* 1 - Authoritative response; 0 - Non-Auth? */
+
+} LSA_R_SAM_LOGON;
+
+
+/* LSA_Q_SAM_LOGOFF */
+typedef struct lsa_q_sam_logoff_info
+{
+ DOM_SAM_INFO sam_id;
+
+} LSA_Q_SAM_LOGOFF;
+
+/* LSA_R_SAM_LOGOFF */
+typedef struct lsa_r_sam_logoff_info
+{
+ uint32 buffer_creds; /* undocumented buffer pointer */
+ DOM_CRED srv_creds; /* server credentials. server time stamp appears to be ignored. */
+
+} LSA_R_SAM_LOGOFF;
+
+#endif
+
+
+#if 0
/*******************************************************************
reads or writes a structure.
********************************************************************/
diff --git a/source/smbparse.c b/source/smbparse.c
index e109f09a6f6..c44c41c4cd9 100644
--- a/source/smbparse.c
+++ b/source/smbparse.c
@@ -2,7 +2,7 @@
Unix SMB/Netbios implementation.
Version 1.9.
Samba utility functions
- Copyright (C) Luke Leighton 1996 - 1997
+ Copyright (C) Luke Leighton 1996 - 1997 Paul Ashton 1997
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
@@ -498,6 +498,41 @@ char* smb_io_dom_r_ref(BOOL io, DOM_R_REF *r_r, char *q, char *base, int align)
return q;
}
+/*******************************************************************
+reads or writes a DOM_NAME structure.
+********************************************************************/
+char* smb_io_dom_name(BOOL io, DOM_NAME *name, char *q, char *base, int align)
+{
+ if (name == NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ RW_IVAL(io, q, name->uni_str_len, 0); q += 4;
+
+ /* don't know if len is specified by uni_str_len member... */
+ /* assume unicode string is unicode-null-terminated, instead */
+
+ q = smb_io_unistr(io, &(name->buffer), q, base, align);
+
+ return q;
+}
+
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+char* smb_io_neg_flags(BOOL io, NEG_FLAGS *neg, char *q, char *base, int align)
+{
+ if (neg == NULL) return NULL;
+
+ q = align_offset(q, base, align);
+
+ RW_IVAL(io, q, neg->neg_flags, 0); q += 4;
+
+ return q;
+}
+
+
#if 0
/*******************************************************************
reads or writes a structure.
--
cgit
From 5bc75c6c626251dc8ba04ff4a83e81b92d93d2d6 Mon Sep 17 00:00:00 2001
From: Luke Leighton
Date: Mon, 6 Oct 1997 14:52:26 +0000
Subject: lsaparse.c smb.h: added 32 bit "return status" to the response
structures.
---
source/include/proto.h | 4 ++
source/include/smb.h | 16 ++++++
source/lsaparse.c | 146 ++++++++++++++++++-------------------------------
3 files changed, 74 insertions(+), 92 deletions(-)
diff --git a/source/include/proto.h b/source/include/proto.h
index a6250ca56c8..9faecd3a003 100644
--- a/source/include/proto.h
+++ b/source/include/proto.h
@@ -325,6 +325,10 @@ char* lsa_io_r_auth_2(BOOL io, LSA_R_AUTH_2 *r_a, char *q, char *base, int align
char* lsa_io_q_srv_pwset(BOOL io, LSA_Q_SRV_PWSET *q_s, char *q, char *base, int align);
char* lsa_io_r_srv_pwset(BOOL io, LSA_R_SRV_PWSET *r_s, char *q, char *base, int align);
char* lsa_io_user_info(BOOL io, LSA_USER_INFO *usr, char *q, char *base, int align);
+char* lsa_io_q_sam_logon(BOOL io, LSA_Q_SAM_LOGON *q_l, char *q, char *base, int align);
+char* lsa_io_r_sam_logon(BOOL io, LSA_R_SAM_LOGON *r_l, char *q, char *base, int align);
+char* lsa_io_q_sam_logoff(BOOL io, LSA_Q_SAM_LOGOFF *q_l, char *q, char *base, int align);
+char* lsa_io_r_sam_logoff(BOOL io, LSA_R_SAM_LOGOFF *r_l, char *q, char *base, int align);
/*The following definitions come from mangle.c */
diff --git a/source/include/smb.h b/source/include/smb.h
index 280147b41f9..1b8f04f02e2 100644
--- a/source/include/smb.h
+++ b/source/include/smb.h
@@ -502,6 +502,8 @@ typedef struct lsa_r_query_info
DOM_QUERY_5 id5;
} dom;
+ uint32 status; /* return code */
+
} LSA_R_QUERY_INFO;
#define MAX_REF_DOMAINS 10
@@ -552,6 +554,8 @@ typedef struct lsa_r_lookup_sids
uint32 num_entries3;
+ uint32 status; /* return code */
+
} LSA_R_LOOKUP_SIDS;
/* DOM_NAME - XXXX not sure about this structure */
@@ -596,6 +600,8 @@ typedef struct lsa_r_lookup_rids
uint32 num_entries3;
+ uint32 status; /* return code */
+
} LSA_R_LOOKUP_RIDS;
@@ -624,6 +630,8 @@ typedef struct lsa_r_req_chal_info
{
DOM_CHAL srv_chal; /* server challenge */
+ uint32 status; /* return code */
+
} LSA_R_REQ_CHAL;
@@ -645,6 +653,8 @@ typedef struct lsa_r_auth2_info
DOM_CHAL srv_chal; /* server-calculated credentials */
NEG_FLAGS srv_flgs; /* usually 0x0000 01ff */
+ uint32 status; /* return code */
+
} LSA_R_AUTH_2;
@@ -661,6 +671,8 @@ typedef struct lsa_r_srv_pwset_info
{
DOM_CHAL srv_chal; /* server-calculated credentials */
+ uint32 status; /* return code */
+
} LSA_R_SRV_PWSET;
#define LSA_MAX_GROUPS 32
@@ -741,6 +753,8 @@ typedef struct lsa_r_sam_logon_info
uint32 auth_resp; /* 1 - Authoritative response; 0 - Non-Auth? */
+ uint32 status; /* return code */
+
} LSA_R_SAM_LOGON;
@@ -757,6 +771,8 @@ typedef struct lsa_r_sam_logoff_info
uint32 buffer_creds; /* undocumented buffer pointer */
DOM_CRED srv_creds; /* server credentials. server time stamp appears to be ignored. */
+ uint32 status; /* return code */
+
} LSA_R_SAM_LOGOFF;
/*
diff --git a/source/lsaparse.c b/source/lsaparse.c
index 68884833f4c..70d4f493800 100644
--- a/source/lsaparse.c
+++ b/source/lsaparse.c
@@ -68,6 +68,9 @@ char* lsa_io_r_query(BOOL io, LSA_R_QUERY_INFO *r_q, char *q, char *base, int al
}
}
}
+
+ RW_IVAL(io, q, r_q->status, 0); q += 4;
+
return q;
}
@@ -127,6 +130,8 @@ char* lsa_io_r_lookup_sids(BOOL io, LSA_R_LOOKUP_SIDS *r_s, char *q, char *base,
RW_IVAL(io, q, r_s->num_entries3, 0); q += 4;
+ RW_IVAL(io, q, r_s->status, 0); q += 4;
+
return q;
}
@@ -182,6 +187,8 @@ char* lsa_io_r_lookup_rids(BOOL io, LSA_R_LOOKUP_RIDS *r_r, char *q, char *base,
RW_IVAL(io, q, r_r->num_entries3, 0); q += 4;
+ RW_IVAL(io, q, r_r->status, 0); q += 4;
+
return q;
}
@@ -212,6 +219,8 @@ char* lsa_io_r_req_chal(BOOL io, LSA_R_REQ_CHAL *r_c, char *q, char *base, int a
q = smb_io_chal(io, &(r_c->srv_chal), q, base, align); /* server challenge */
+ RW_IVAL(io, q, r_c->status, 0); q += 4;
+
return q;
}
@@ -244,6 +253,8 @@ char* lsa_io_r_auth_2(BOOL io, LSA_R_AUTH_2 *r_a, char *q, char *base, int align
q = smb_io_chal (io, &(r_a->srv_chal), q, base, align); /* server challenge */
q = smb_io_neg_flags(io, &(r_a->srv_flgs), q, base, align);
+ RW_IVAL(io, q, r_a->status, 0); q += 4;
+
return q;
}
@@ -274,6 +285,8 @@ char* lsa_io_r_srv_pwset(BOOL io, LSA_R_SRV_PWSET *r_s, char *q, char *base, int
q = smb_io_chal(io, &(r_s->srv_chal), q, base, align); /* server challenge */
+ RW_IVAL(io, q, r_s->status, 0); q += 4;
+
return q;
}
@@ -349,125 +362,72 @@ char* lsa_io_user_info(BOOL io, LSA_USER_INFO *usr, char *q, char *base, int ali
return q;
}
-
-#if 0
/*******************************************************************
reads or writes a structure.
********************************************************************/
- char* lsa_io_(BOOL io, *, char *q, char *base, int align)
+char* lsa_io_q_sam_logon(BOOL io, LSA_Q_SAM_LOGON *q_l, char *q, char *base, int align)
{
- if (== NULL) return NULL;
+ if (q_l == NULL) return NULL;
q = align_offset(q, base, align);
- RW_IVAL(io, q, , 0); q += 4;
+ q = smb_io_sam_info(io, &(q_l->sam_id), q, base, align); /* domain SID */
return q;
}
-#endif
-
-
-#if 0 /* to be done... */
-
-#define LSA_MAX_GROUPS 32
-
-/* LSA_USER_INFO */
-typedef struct lsa_q_user_info
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+char* lsa_io_r_sam_logon(BOOL io, LSA_R_SAM_LOGON *r_l, char *q, char *base, int align)
{
- uint32 undoc_buffer;
-
- NTTIME logon_time; /* logon time */
- NTTIME logoff_time; /* logoff time */
- NTTIME kickoff_time; /* kickoff time */
- NTTIME pass_last_set_time; /* password last set time */
- NTTIME pass_can_change_time; /* password can change time */
- NTTIME pass_must_change_time; /* password must change time */
+ if (r_l == NULL) return NULL;
- UNIHDR hdr_user_name; /* username unicode string header */
- UNIHDR hdr_full_name; /* user's full name unicode string header */
- UNIHDR hdr_logon_script; /* logon script unicode string header */
- UNIHDR hdr_profile_path; /* profile path unicode string header */
- UNIHDR hdr_home_dir; /* home directory unicode string header */
- UNIHDR hdr_dir_drive; /* home directory drive unicode string header */
-
- uint16 logon_count; /* logon count */
- uint16 bad_pw_count; /* bad password count */
-
- uint32 user_id; /* User ID */
- uint32 group_id; /* Group ID */
- uint32 num_groups; /* num groups */
- uint32 buffer_groups; /* undocumented buffer pointer to groups. */
- uint32 user_flgs; /* user flags */
-
- char sess_key[16]; /* unused user session key */
-
- UNIHDR hdr_logon_srv; /* logon server unicode string header */
- UNIHDR hdr_logon_dom; /* logon domain unicode string header */
-
- uint32 buffer_dom_id; /* undocumented logon domain id pointer */
- char padding[40]; /* unused padding bytes? */
-
- uint32 num_sids; /* 0 - num_sids */
- uint32 buffer_sids; /* NULL - undocumented pointer to SIDs. */
+ q = align_offset(q, base, align);
- UNISTR2 uni_user_name; /* username unicode string */
- UNISTR2 uni_full_name; /* user's full name unicode string */
- UNISTR2 uni_logon_script; /* logon script unicode string */
- UNISTR2 uni_profile_path; /* profile path unicode string */
- UNISTR2 uni_home_dir; /* home directory unicode string */
- UNISTR2 uni_dir_drive; /* home directory drive unicode string */
+ RW_IVAL(io, q, r_l->buffer_creds, 0); q += 4; /* undocumented buffer pointer */
+ q = smb_io_cred(io, &(r_l->srv_creds), q, base, align); /* server credentials. server time stamp appears to be ignored. */
- uint32 num_groups2; /* num groups */
- DOM_GID gids[LSA_MAX_GROUPS]; /* group info */
+ RW_IVAL(io, q, r_l->buffer_user, 0); q += 4;
+ q = lsa_io_user_info(io, &(r_l->user), q, base, align);
- UNISTR2 uni_logon_srv; /* logon server unicode string */
- UNISTR2 uni_logon_dom; /* logon domain unicode string */
+ RW_IVAL(io, q, r_l->auth_resp, 0); q += 4; /* 1 - Authoritative response; 0 - Non-Auth? */
- DOM_SID undoc_dom_sids[2]; /* undocumented - domain SIDs */
- DOM_SID dom_sid; /* domain SID */
+ RW_IVAL(io, q, r_l->status, 0); q += 4;
-} LSA_USER_INFO;
-
-
-/* LSA_Q_SAM_LOGON */
-typedef struct lsa_q_sam_logon_info
-{
- DOM_SAM_INFO sam_id;
-
-} LSA_Q_SAM_LOGON;
+ return q;
+}
-/* LSA_R_SAM_LOGON */
-typedef struct lsa_r_sam_logon_info
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+char* lsa_io_q_sam_logoff(BOOL io, LSA_Q_SAM_LOGOFF *q_l, char *q, char *base, int align)
{
- uint32 buffer_creds; /* undocumented buffer pointer */
- DOM_CRED srv_creds; /* server credentials. server time stamp appears to be ignored. */
-
- uint32 buffer_user;
- LSA_USER_INFO user;
-
- uint32 auth_resp; /* 1 - Authoritative response; 0 - Non-Auth? */
+ if (q_l == NULL) return NULL;
-} LSA_R_SAM_LOGON;
+ q = align_offset(q, base, align);
+
+ q = smb_io_sam_info(io, &(q_l->sam_id), q, base, align); /* domain SID */
+ return q;
+}
-/* LSA_Q_SAM_LOGOFF */
-typedef struct lsa_q_sam_logoff_info
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+char* lsa_io_r_sam_logoff(BOOL io, LSA_R_SAM_LOGOFF *r_l, char *q, char *base, int align)
{
- DOM_SAM_INFO sam_id;
+ if (r_l == NULL) return NULL;
-} LSA_Q_SAM_LOGOFF;
-
-/* LSA_R_SAM_LOGOFF */
-typedef struct lsa_r_sam_logoff_info
-{
- uint32 buffer_creds; /* undocumented buffer pointer */
- DOM_CRED srv_creds; /* server credentials. server time stamp appears to be ignored. */
-
-} LSA_R_SAM_LOGOFF;
+ q = align_offset(q, base, align);
+
+ RW_IVAL(io, q, r_l->buffer_creds, 0); q += 4; /* undocumented buffer pointer */
+ q = smb_io_cred(io, &(r_l->srv_creds), q, base, align); /* server credentials. server time stamp appears to be ignored. */
-#endif
+ RW_IVAL(io, q, r_l->status, 0); q += 4;
+ return q;
+}
#if 0
/*******************************************************************
@@ -484,3 +444,5 @@ reads or writes a structure.
return q;
}
#endif
+
+
--
cgit
From b93509846d6291771787af457500eec8984ee6bd Mon Sep 17 00:00:00 2001
From: Jeremy Allison
Date: Mon, 6 Oct 1997 17:52:25 +0000
Subject: client.c: Changed shadowed variable. locking.c: Removed USE_OPLOCKS -
now the default. params.c: Removed unused variable. proto.h: Updated.
reply.c: Removed USE_OPLOCKS - now the default. server.c: Removed USE_OPLOCKS
- now the default. smb.h: Removed USE_OPLOCKS - now the default. smbparse.c:
Changed shadowed variable. status.c: Removed USE_OPLOCKS - now the default.
util.c: Removed USE_OPLOCKS - now the default. Jeremy (jallison@whistle.com)
---
source/client/client.c | 8 ++++----
source/include/proto.h | 4 ++--
source/include/smb.h | 24 +++++-------------------
source/lib/util.c | 8 +++-----
source/locking/locking.c | 18 ------------------
source/param/params.c | 1 -
source/smbd/reply.c | 6 +-----
source/smbd/server.c | 26 --------------------------
source/smbparse.c | 8 ++++----
source/utils/status.c | 15 ++-------------
10 files changed, 21 insertions(+), 97 deletions(-)
diff --git a/source/client/client.c b/source/client/client.c
index 403eea2fc99..6d85bd8807f 100644
--- a/source/client/client.c
+++ b/source/client/client.c
@@ -4562,12 +4562,12 @@ static void usage(char *pname)
break;
case 'U':
{
- char *p;
+ char *lp;
strcpy(username,optarg);
- if ((p=strchr(username,'%')))
+ if ((lp=strchr(username,'%')))
{
- *p = 0;
- strcpy(password,p+1);
+ *lp = 0;
+ strcpy(password,lp+1);
got_pass = True;
memset(strchr(optarg,'%')+1,'X',strlen(password));
}
diff --git a/source/include/proto.h b/source/include/proto.h
index 9faecd3a003..202b1511504 100644
--- a/source/include/proto.h
+++ b/source/include/proto.h
@@ -808,7 +808,7 @@ char* smb_io_chal(BOOL io, DOM_CHAL *chal, char *q, char *base, int align);
char* smb_io_cred(BOOL io, DOM_CRED *cred, char *q, char *base, int align);
char* smb_io_clnt_info(BOOL io, DOM_CLNT_INFO *clnt, char *q, char *base, int align);
char* smb_io_logon_id(BOOL io, DOM_LOGON_ID *log, char *q, char *base, int align);
-char* smb_io_rc4_owf(BOOL io, RC4_OWF *hash, char *q, char *base, int align);
+char* smb_io_arc4_owf(BOOL io, ARC4_OWF *hash, char *q, char *base, int align);
char* smb_io_id_info1(BOOL io, DOM_ID_INFO_1 *id, char *q, char *base, int align);
char* smb_io_sam_info(BOOL io, DOM_SAM_INFO *sam, char *q, char *base, int align);
char* smb_io_gid(BOOL io, DOM_GID *gid, char *q, char *base, int align);
@@ -1045,4 +1045,4 @@ void fstrcpy(char *dest, char *src);
void pstrcpy(char *dest, char *src);
char *align4(char *q, char *base);
char *align2(char *q, char *base);
-char *align_offset(char *q, char *base, int align_offset);
+char *align_offset(char *q, char *base, int align_offset_len);
diff --git a/source/include/smb.h b/source/include/smb.h
index 1b8f04f02e2..43e402359f0 100644
--- a/source/include/smb.h
+++ b/source/include/smb.h
@@ -393,12 +393,12 @@ typedef struct logon_info
} DOM_LOGON_ID;
-/* RC4_OWF */
-typedef struct rc4_owf_info
+/* ARC4_OWF */
+typedef struct arc4_owf_info
{
uint8 data[16];
-} RC4_OWF;
+} ARC4_OWF;
/* DOM_ID_INFO_1 */
@@ -409,8 +409,8 @@ typedef struct id_info_1
DOM_LOGON_ID logon_id; /* logon ID */
UNIHDR hdr_user_name; /* user name unicode header */
UNIHDR hdr_workgroup_name; /* workgroup name unicode header */
- RC4_OWF rc4_lm_owf; /* rc4 LM OWF Password */
- RC4_OWF rc4_nt_owf; /* rc4 NT OWF Password */
+ ARC4_OWF arc4_lm_owf; /* arc4 LM OWF Password */
+ ARC4_OWF arc4_nt_owf; /* arc4 NT OWF Password */
UNISTR2 uni_domain_name; /* domain name unicode string */
UNISTR2 uni_user_name; /* user name unicode string */
UNISTR2 uni_workgroup_name; /* workgroup name unicode string */
@@ -1040,10 +1040,8 @@ typedef struct
{
smb_shm_offset_t next_share_mode_entry;
int pid;
-#ifdef USE_OPLOCKS
uint16 op_port;
uint16 op_type;
-#endif /* USE_OPLOCKS */
int share_mode;
struct timeval time;
} share_mode_entry;
@@ -1052,10 +1050,8 @@ typedef struct
typedef struct
{
int pid;
-#ifdef USE_OPLOCKS
uint16 op_port;
uint16 op_type;
-#endif /* USE_OPLOCKS */
int share_mode;
struct timeval time;
} min_share_mode_entry;
@@ -1081,11 +1077,7 @@ struct connect_record
};
#ifndef LOCKING_VERSION
-#ifdef USE_OPLOCKS
#define LOCKING_VERSION 4
-#else /* USE_OPLOCKS */
-#define LOCKING_VERSION 3
-#endif /* USE_OPLOCKS */
#endif /* LOCKING_VERSION */
#if !defined(FAST_SHARE_MODES)
@@ -1101,11 +1093,7 @@ struct connect_record
#define SMF_FILENAME_LEN_OFFSET 8
#define SMF_HEADER_LENGTH 10
-#ifdef USE_OPLOCKS
#define SMF_ENTRY_LENGTH 20
-#else /* USE_OPLOCKS */
-#define SMF_ENTRY_LENGTH 16
-#endif /* USE_OPLOCKS */
/*
* Share mode record offsets.
@@ -1116,10 +1104,8 @@ struct connect_record
#define SME_SHAREMODE_OFFSET 8
#define SME_PID_OFFSET 12
-#ifdef USE_OPLOCKS
#define SME_PORT_OFFSET 16
#define SME_OPLOCK_TYPE_OFFSET 18
-#endif /* USE_OPLOCKS */
#endif /* FAST_SHARE_MODES */
diff --git a/source/lib/util.c b/source/lib/util.c
index c5cfdd99f75..611794c4a86 100644
--- a/source/lib/util.c
+++ b/source/lib/util.c
@@ -2301,7 +2301,6 @@ BOOL receive_smb(int fd,char *buffer, int timeout)
return(True);
}
-#ifdef USE_OPLOCKS
/****************************************************************************
read a message from a udp fd.
The timeout is in milli seconds
@@ -2498,7 +2497,6 @@ BOOL receive_message_or_smb(int smbfd, int oplock_fd,
return receive_local_message(oplock_fd, buffer, buffer_len, 0);
}
}
-#endif /* USE_OPLOCKS */
/****************************************************************************
send an smb to a fd
@@ -4335,11 +4333,11 @@ char *align2(char *q, char *base)
align a pointer to a multiple of align_offset bytes. looks like it
will work for offsets of 0, 2 and 4...
********************************************************************/
-char *align_offset(char *q, char *base, int align_offset)
+char *align_offset(char *q, char *base, int align_offset_len)
{
- if (align_offset != 0 && ((q - base) & (align_offset-1)))
+ if (align_offset_len != 0 && ((q - base) & (align_offset_len-1)))
{
- q += align_offset - ((q - base) & (align_offset));
+ q += align_offset_len - ((q - base) & (align_offset_len));
}
return q;
}
diff --git a/source/locking/locking.c b/source/locking/locking.c
index abda5d39d47..f29c1a6105a 100644
--- a/source/locking/locking.c
+++ b/source/locking/locking.c
@@ -283,10 +283,8 @@ bucket %d (number of entries now = %d)\n",
*/
share_array[num_entries_copied].pid = entry_scanner_p->pid;
share_array[num_entries_copied].share_mode = entry_scanner_p->share_mode;
-#ifdef USE_OPLOCKS
share_array[num_entries_copied].op_port = entry_scanner_p->op_port;
share_array[num_entries_copied].op_type = entry_scanner_p->op_type;
-#endif /* USE_OPLOCKS */
memcpy(&share_array[num_entries_copied].time, &entry_scanner_p->time,
sizeof(struct timeval));
num_entries_copied++;
@@ -555,10 +553,8 @@ inode %d in hash bucket %d\n", fs_p->name, dev, inode, hash_entry));
new_entry_p->pid = getpid();
new_entry_p->share_mode = fs_p->share_mode;
-#ifdef USE_OPLOCKS
new_entry_p->op_port = port;
new_entry_p->op_type = op_type;
-#endif /* USE_OPLOCKS */
memcpy( (char *)&new_entry_p->time, (char *)&fs_p->open_time, sizeof(struct timeval));
/* Chain onto the share_mode_record */
@@ -589,7 +585,6 @@ Remove an oplock port and mode entry from a share mode.
********************************************************************/
BOOL remove_share_oplock(int fnum, share_lock_token token)
{
-#ifdef USE_OPLOCKS
uint32 dev, inode;
smb_shm_offset_t *mode_array;
unsigned int hash_entry;
@@ -694,9 +689,6 @@ mode record found dev = %d, inode = %d in hash bucket %d\n", dev, inode, hash_en
}
return True;
-#else /* USE_OPLOCKS */
- return False;
-#endif /* USE_OPLOCKS */
}
#else /* FAST_SHARE_MODES */
@@ -1006,10 +998,8 @@ it left a share mode entry with mode 0x%X in share file %s\n",
share_array[num_entries_copied].time.tv_usec = IVAL(p,SME_USEC_OFFSET);
share_array[num_entries_copied].share_mode = IVAL(p,SME_SHAREMODE_OFFSET);
share_array[num_entries_copied].pid = pid;
-#ifdef USE_OPLOCKS
share_array[num_entries_copied].op_port = SVAL(p,SME_PORT_OFFSET);
share_array[num_entries_copied].op_type = SVAL(p,SME_OPLOCK_TYPE_OFFSET);
-#endif /* USE_OPLOCKS */
num_entries_copied++;
}
@@ -1054,10 +1044,8 @@ position 0 for share mode file %s (%s)\n", fname, strerror(errno)));
SIVAL(p,SME_SHAREMODE_OFFSET,share_array[i].share_mode);
SIVAL(p,SME_SEC_OFFSET,share_array[i].time.tv_sec);
SIVAL(p,SME_USEC_OFFSET,share_array[i].time.tv_usec);
-#ifdef USE_OPLOCKS
SSVAL(p,SME_PORT_OFFSET,share_array[i].op_port);
SSVAL(p,SME_OPLOCK_TYPE_OFFSET,share_array[i].op_type);
-#endif /* USE_OPLOCKS */
}
newsize = (base - buf) + (SMF_ENTRY_LENGTH*num_entries_copied);
@@ -1338,10 +1326,8 @@ deleting it.\n", fname));
SIVAL(p,SME_USEC_OFFSET,fs_p->open_time.tv_usec);
SIVAL(p,SME_SHAREMODE_OFFSET,fs_p->share_mode);
SIVAL(p,SME_PID_OFFSET,pid);
-#ifdef USE_OPLOCKS
SSVAL(p,SME_PORT_OFFSET,port);
SSVAL(p,SME_OPLOCK_TYPE_OFFSET,op_type);
-#endif /* USE_OPLOCKS */
num_entries++;
@@ -1392,7 +1378,6 @@ Remove an oplock port and mode entry from a share mode.
********************************************************************/
BOOL remove_share_oplock(int fnum, share_lock_token token)
{
-#ifdef USE_OPLOCKS
pstring fname;
int fd = (int)token;
char *buf = 0;
@@ -1504,8 +1489,5 @@ mode file %s (%s)\n", fname, strerror(errno)));
return True;
-#else /* USE_OPLOCKS */
- return False;
-#endif /* USE_OPLOCKS */
}
#endif /* FAST_SHARE_MODES */
diff --git a/source/param/params.c b/source/param/params.c
index 8c41eef789f..4d1c191b479 100644
--- a/source/param/params.c
+++ b/source/param/params.c
@@ -441,7 +441,6 @@ static BOOL Parse( FILE *InFile,
*/
{
int c;
- char *func = "params.c:Parse() -";
c = EatWhitespace( InFile );
while( (EOF != c) && (c > 0) )
diff --git a/source/smbd/reply.c b/source/smbd/reply.c
index a8f674183c5..fa641931eb2 100644
--- a/source/smbd/reply.c
+++ b/source/smbd/reply.c
@@ -1621,7 +1621,6 @@ int reply_readbraw(char *inbuf, char *outbuf)
int fd;
char *fname;
-#ifdef USE_OPLOCKS
/*
* Special check if an oplock break has been issued
* and the readraw request croses on the wire, we must
@@ -1635,7 +1634,6 @@ int reply_readbraw(char *inbuf, char *outbuf)
DEBUG(5,("readbraw - oplock break finished\n"));
return -1;
}
-#endif
cnum = SVAL(inbuf,smb_tid);
fnum = GETFNUM(inbuf,smb_vwv0);
@@ -3373,7 +3371,7 @@ int reply_lockingX(char *inbuf,char *outbuf,int length,int bufsize)
unsigned char locktype = CVAL(inbuf,smb_vwv3);
#if 0
unsigned char oplocklevel = CVAL(inbuf,smb_vwv3+1);
-#endif /* USE_OPLOCKS */
+#endif
uint16 num_ulocks = SVAL(inbuf,smb_vwv6);
uint16 num_locks = SVAL(inbuf,smb_vwv7);
uint32 count, offset;
@@ -3391,7 +3389,6 @@ int reply_lockingX(char *inbuf,char *outbuf,int length,int bufsize)
data = smb_buf(inbuf);
-#ifdef USE_OPLOCKS
/* Check if this is an oplock break on a file
we have granted an oplock on.
*/
@@ -3432,7 +3429,6 @@ dev = %x, inode = %x\n", fnum, dev, inode));
fsp->granted_oplock = False;
return -1;
}
-#endif /* USE_OPLOCKS */
/* Data now points at the beginning of the list
of smb_unlkrng structs */
diff --git a/source/smbd/server.c b/source/smbd/server.c
index 826b17121fd..4f5b01ba91e 100644
--- a/source/smbd/server.c
+++ b/source/smbd/server.c
@@ -84,13 +84,11 @@ int chain_fnum = -1;
/* number of open connections */
static int num_connections_open = 0;
-#ifdef USE_OPLOCKS
/* Oplock ipc UDP socket. */
int oplock_sock = -1;
uint16 oplock_port = 0;
/* Current number of oplocks we have outstanding. */
int32 global_oplocks_open = 0;
-#endif /* USE_OPLOCKS */
BOOL global_oplock_break = False;
@@ -1487,7 +1485,6 @@ BOOL check_file_sharing(int cnum,char *fname)
{
min_share_mode_entry *share_entry = &old_shares[i];
-#ifdef USE_OPLOCKS
/*
* Break oplocks before checking share modes. See comment in
* open_file_shared for details.
@@ -1513,7 +1510,6 @@ dev = %x, inode = %x\n", old_shares[i].op_type, fname, dev, inode));
broke_oplock = True;
break;
}
-#endif /* USE_OPLOCKS */
/* someone else has a share lock on it, check to see
if we can too */
@@ -1729,7 +1725,6 @@ void open_file_shared(int fnum,int cnum,char *fname,int share_mode,int ofun,
{
min_share_mode_entry *share_entry = &old_shares[i];
-#ifdef USE_OPLOCKS
/*
* By observation of NetBench, oplocks are broken *before* share
* modes are checked. This allows a file to be closed by the client
@@ -1759,7 +1754,6 @@ dev = %x, inode = %x\n", old_shares[i].op_type, fname, dev, inode));
broke_oplock = True;
break;
}
-#endif /* USE_OPLOCKS */
/* someone else has a share lock on it, check to see
if we can too */
@@ -1841,7 +1835,6 @@ dev = %x, inode = %x\n", old_shares[i].op_type, fname, dev, inode));
if (lp_share_modes(SNUM(cnum)))
{
uint16 port = 0;
-#ifdef USE_OPLOCKS
/* JRA. Currently this only services Exlcusive and batch
oplocks (no other opens on this file). This needs to
be extended to level II oplocks (multiple reader
@@ -1862,10 +1855,6 @@ dev = %x, inode = %x\n", oplock_request, fname, dev, inode));
port = 0;
oplock_request = 0;
}
-#else /* USE_OPLOCKS */
- oplock_request = 0;
- port = 0;
-#endif /* USE_OPLOCKS */
set_share_mode(token, fnum, port, oplock_request);
}
@@ -2434,7 +2423,6 @@ static void process_smb(char *inbuf, char *outbuf)
trans_num++;
}
-#ifdef USE_OPLOCKS
/****************************************************************************
open the oplock IPC socket communication
****************************************************************************/
@@ -2882,8 +2870,6 @@ oplock break response from pid %d on port %d for dev = %x, inode = %x.\n",
return True;
}
-#endif /* USE_OPLOCKS */
-
/****************************************************************************
check if a snum is in use
****************************************************************************/
@@ -4588,9 +4574,7 @@ static void process(void)
int counter;
int last_keepalive=0;
int service_load_counter = 0;
-#ifdef USE_OPLOCKS
BOOL got_smb = False;
-#endif /* USE_OPLOCKS */
if (deadtime <= 0)
deadtime = DEFAULT_SMBD_TIMEOUT;
@@ -4601,12 +4585,8 @@ static void process(void)
errno = 0;
for (counter=SMBD_SELECT_LOOP;
-#ifdef USE_OPLOCKS
!receive_message_or_smb(Client,oplock_sock,
InBuffer,BUFFER_SIZE,SMBD_SELECT_LOOP*1000,&got_smb);
-#else /* USE_OPLOCKS */
- !receive_smb(Client,InBuffer,SMBD_SELECT_LOOP*1000);
-#endif /* USE_OPLOCKS */
counter += SMBD_SELECT_LOOP)
{
int i;
@@ -4689,14 +4669,10 @@ static void process(void)
}
}
-#ifdef USE_OPLOCKS
if(got_smb)
-#endif /* USE_OPLOCKS */
process_smb(InBuffer, OutBuffer);
-#ifdef USE_OPLOCKS
else
process_local_message(oplock_sock, InBuffer, BUFFER_SIZE);
-#endif /* USE_OPLOCKS */
}
}
@@ -4976,11 +4952,9 @@ static void usage(char *pname)
DEBUG(2,("%s changed root to %s\n",timestring(),lp_rootdir()));
}
-#ifdef USE_OPLOCKS
/* Setup the oplock IPC socket. */
if(!open_oplock_ipc())
exit(1);
-#endif /* USE_OPLOCKS */
process();
close_sockets();
diff --git a/source/smbparse.c b/source/smbparse.c
index c44c41c4cd9..95390522ff5 100644
--- a/source/smbparse.c
+++ b/source/smbparse.c
@@ -296,9 +296,9 @@ char* smb_io_logon_id(BOOL io, DOM_LOGON_ID *log, char *q, char *base, int align
}
/*******************************************************************
-reads or writes an RC4_OWF structure.
+reads or writes an ARC4_OWF structure.
********************************************************************/
-char* smb_io_rc4_owf(BOOL io, RC4_OWF *hash, char *q, char *base, int align)
+char* smb_io_arc4_owf(BOOL io, ARC4_OWF *hash, char *q, char *base, int align)
{
if (hash == NULL) return NULL;
@@ -326,8 +326,8 @@ char* smb_io_id_info1(BOOL io, DOM_ID_INFO_1 *id, char *q, char *base, int align
q = smb_io_unihdr(io, &(id->hdr_user_name ), q, base, align);
q = smb_io_unihdr(io, &(id->hdr_workgroup_name), q, base, align);
- q = smb_io_rc4_owf(io, &(id->rc4_lm_owf), q, base, align);
- q = smb_io_rc4_owf(io, &(id->rc4_nt_owf), q, base, align);
+ q = smb_io_arc4_owf(io, &(id->arc4_lm_owf), q, base, align);
+ q = smb_io_arc4_owf(io, &(id->arc4_nt_owf), q, base, align);
q = smb_io_unistr2(io, &(id->uni_domain_name ), q, base, align);
q = smb_io_unistr2(io, &(id->uni_user_name ), q, base, align);
diff --git a/source/utils/status.c b/source/utils/status.c
index 703105012ef..4143244ab4d 100644
--- a/source/utils/status.c
+++ b/source/utils/status.c
@@ -148,9 +148,7 @@ locking version (was %d, should be %d).\n",fname,
void *dir;
char *s;
#endif /* FAST_SHARE_MODES */
-#ifdef USE_OPLOCKS
int oplock_type;
-#endif /* USE_OPLOCKS */
int i;
struct session_record *ptr;
@@ -347,9 +345,7 @@ locking version (was %d, should be %d).\n",fname,
t.tv_sec = entry_scanner_p->time.tv_sec;
t.tv_usec = entry_scanner_p->time.tv_usec;
strcpy(fname, file_scanner_p->file_name);
-#ifdef USE_OPLOCKS
oplock_type = entry_scanner_p->op_type;
-#endif /* USE_OPLOCKS */
#else /* FAST_SHARE_MODES */
@@ -411,9 +407,7 @@ locking version (was %d, should be %d).\n",fname,
t.tv_sec = IVAL(p,SME_SEC_OFFSET);
t.tv_usec = IVAL(p,SME_USEC_OFFSET);
-#ifdef USE_OPLOCKS
oplock_type = SVAL(p,SME_OPLOCK_TYPE_OFFSET);
-#endif /* USE_OPLOCKS */
#endif /* FAST_SHARE_MODES */
fname[sizeof(fname)-1] = 0;
@@ -421,13 +415,8 @@ locking version (was %d, should be %d).\n",fname,
if (firstopen) {
firstopen=False;
printf("Locked files:\n");
-#ifdef USE_OPLOCKS
printf("Pid DenyMode R/W Oplock Name\n");
printf("--------------------------------------------------\n");
-#else /* USE_OPLOCKS */
- printf("Pid DenyMode R/W Name\n");
- printf("----------------------------------\n");
-#endif /* USE_OPLOCKS */
}
@@ -446,7 +435,7 @@ locking version (was %d, should be %d).\n",fname,
case 1: printf("WRONLY "); break;
case 2: printf("RDWR "); break;
}
-#ifdef USE_OPLOCKS
+
if((oplock_type & (EXCLUSIVE_OPLOCK|BATCH_OPLOCK)) == (EXCLUSIVE_OPLOCK|BATCH_OPLOCK))
printf("EXCLUSIVE+BATCH ");
else if (oplock_type & EXCLUSIVE_OPLOCK)
@@ -455,7 +444,7 @@ locking version (was %d, should be %d).\n",fname,
printf("BATCH ");
else
printf("NONE ");
-#endif /* USE_OPLOCKS */
+
printf(" %s %s",fname,asctime(LocalTime((time_t *)&t.tv_sec)));
#ifdef FAST_SHARE_MODES
--
cgit
From db4c2cb50e11d252ff3ba0e0973767e909dd33bd Mon Sep 17 00:00:00 2001
From: Jeremy Allison
Date: Mon, 6 Oct 1997 19:50:51 +0000
Subject: Finally ! Found & fixed crash bug with logging message when deleting
invalid share mode entries. Thanks to berg@wienrg.aut.alcatel.at (Dietmar
Berg) for the stack backtrace. Jeremy (jallison@whistle.com)
---
source/locking/locking.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/source/locking/locking.c b/source/locking/locking.c
index f29c1a6105a..6e321d0626e 100644
--- a/source/locking/locking.c
+++ b/source/locking/locking.c
@@ -241,6 +241,7 @@ bucket %d\n", file_scanner_p->locking_version, dev, inode, hash_entry));
{
/* Delete this share mode entry */
share_mode_entry *delete_entry_p = entry_scanner_p;
+ int share_mode = entry_scanner_p->share_mode;
if(entry_prev_p == entry_scanner_p)
{
@@ -271,7 +272,7 @@ for dev = %d, ino = %d, hashbucket %d\n", file_scanner_p->num_share_mode_entries
DEBUG(0,("get_share_modes (FAST_SHARE_MODES): process %d no longer exists and \
it left a share mode entry with mode 0x%X for file dev = %d, ino = %d in hash \
bucket %d (number of entries now = %d)\n",
- pid, entry_scanner_p->share_mode, dev, inode, hash_entry,
+ pid, share_mode, dev, inode, hash_entry,
file_scanner_p->num_share_mode_entries));
smb_shm_free(smb_shm_addr2offset(delete_entry_p));
--
cgit
From 1de1a22d0cd4ca1a977f35411ca57ce0768a46d7 Mon Sep 17 00:00:00 2001
From: Jeremy Allison
Date: Mon, 6 Oct 1997 19:54:33 +0000
Subject: locking.c: Finally fixed nasty crash bug when deleting invalid share
mode entries. util.c: Tried to stop put_ip core dump seemingly caused by bad
returns from gethostbyname. Jeremy (jallison@whistle.com)
---
source/lib/util.c | 4 ++++
source/locking/locking.c | 7 ++++---
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/source/lib/util.c b/source/lib/util.c
index 0c4999c789c..7f785332e6a 100644
--- a/source/lib/util.c
+++ b/source/lib/util.c
@@ -3150,6 +3150,10 @@ uint32 interpret_addr(char *str)
DEBUG(3,("Get_Hostbyname: Unknown host. %s\n",str));
return 0;
}
+ if(hp->h_addr == NULL) {
+ DEBUG(3,("Get_Hostbyname: host address is invalid for host %s.\n",str));
+ return 0;
+ }
putip((char *)&res,(char *)hp->h_addr);
}
diff --git a/source/locking/locking.c b/source/locking/locking.c
index c2a06cac75c..868902963fe 100644
--- a/source/locking/locking.c
+++ b/source/locking/locking.c
@@ -206,7 +206,7 @@ file dev = %d, ino = %d in hash_bucket %d\n", dev, inode, hash_entry));
{
DEBUG(0,("ERROR:get_share_modes (FAST_SHARE_MODES): Deleting old share mode \
record due to old locking version %d for file dev = %d, inode = %d in hash \
-bucket %d",file_scanner_p->locking_version, dev, inode, hash_entry));
+bucket %d\n",file_scanner_p->locking_version, dev, inode, hash_entry));
if(file_prev_p == file_scanner_p)
mode_array[hash_entry] = file_scanner_p->next_offset;
else
@@ -241,6 +241,7 @@ bucket %d",file_scanner_p->locking_version, dev, inode, hash_entry));
{
/* Delete this share mode entry */
share_mode_entry *delete_entry_p = entry_scanner_p;
+ int share_mode = entry_scanner_p->share_mode;
if(entry_prev_p == entry_scanner_p)
{
@@ -270,8 +271,8 @@ for dev = %d, ino = %d, hashbucket %d\n", file_scanner_p->num_share_mode_entries
DEBUG(0,("get_share_modes (FAST_SHARE_MODES): process %d no longer exists and \
it left a share mode entry with mode 0x%X for file dev = %d, ino = %d in hash \
-bucket (number of entries now = %d)\n",
- pid, entry_scanner_p->share_mode, dev, inode, hash_entry,
+bucket %d (number of entries now = %d)\n",
+ pid, share_mode, dev, inode, hash_entry,
file_scanner_p->num_share_mode_entries));
smb_shm_free(smb_shm_addr2offset(delete_entry_p));
--
cgit
From d808df8191cdf21b011e773e6e99b0c65524253c Mon Sep 17 00:00:00 2001
From: Samba Release Account
Date: Tue, 7 Oct 1997 04:47:23 +0000
Subject: Removed samba.faq from the docs directory, it was out of date. All
FAQs in docs/faq.
Replaced all reference to samba.canberra.edu.au/pub/samba/samba.html
with samba.anu.edu.au/samba/
Replaced references to ictinus@lake.canberra.edu.au
with ictinus@samba.anu.edu.au
Added 3 new mirrors, Greece, Poland, Romania
Paul.
---
docs/announce | 2 +-
docs/faq/Samba-Server-FAQ.sgml | 6 +-
docs/faq/Samba-meta-FAQ-2.html | 2 +-
docs/faq/Samba-meta-FAQ.sgml | 8 +-
docs/faq/Samba-meta-FAQ.txt | 433 ++++++++++++++------
docs/faq/sambafaq-1.html | 2 +-
docs/faq/sambafaq-3.html | 2 +-
docs/faq/sambafaq.sgml | 11 +-
docs/faq/sambafaq.txt | 310 +++++++-------
docs/manpages/samba.7 | 2 +-
docs/samba.faq | 900 -----------------------------------------
docs/textdocs/BUGS.txt | 2 +-
docs/textdocs/MIRRORS.txt | 11 +-
docs/textdocs/UNIX_INSTALL.txt | 2 +-
14 files changed, 506 insertions(+), 1187 deletions(-)
delete mode 100644 docs/samba.faq
diff --git a/docs/announce b/docs/announce
index adcde8966f8..a03ddcd0e6a 100644
--- a/docs/announce
+++ b/docs/announce
@@ -127,7 +127,7 @@ There is also often quite a bit of discussion about Samba on the
newsgroup comp.protocols.smb.
A WWW site with lots of Samba info can be found at
-http://samba.canberra.edu.au/pub/samba/
+http://samba.anu.edu.au/samba/
The Samba Team (Contact: samba-bugs@samba.anu.edu.au)
June 1996
diff --git a/docs/faq/Samba-Server-FAQ.sgml b/docs/faq/Samba-Server-FAQ.sgml
index 4887481e2b1..020d5322811 100644
--- a/docs/faq/Samba-Server-FAQ.sgml
+++ b/docs/faq/Samba-Server-FAQ.sgml
@@ -3,7 +3,7 @@
v 0.1 23 Aug 1997 Dan Shearer
Original Samba-Client-FAQ.sgml from Paul's sambafaq.sgml
v 0.2 25 Aug 1997 Dan
-
+ v 0.3 7 Oct 1997 Paul, changed email address from ictinus@lake... to ictinus@samba.anu
-->
@@ -11,9 +11,9 @@
Samba Server FAQ
-Dan Shearer & Paul Blackman, ictinus@lake.canberra.edu.au
+Dan Shearer & Paul Blackman, ictinus@samba.anu.edu.au
-v 0.1, 23 Aug '97
+v 0.3, 7 Oct '97
This is the Server Frequently Asked Questions (FAQ)
document for Samba, the free and very popular SMB and CIFS server
diff --git a/docs/faq/Samba-meta-FAQ-2.html b/docs/faq/Samba-meta-FAQ-2.html
index c5ebab7e7e4..ac760380067 100644
--- a/docs/faq/Samba-meta-FAQ-2.html
+++ b/docs/faq/Samba-meta-FAQ-2.html
@@ -166,7 +166,7 @@ See below for subscription information.
discussion about Samba.
The WWW site 'SAMBA Web Pages' at
-http://samba.canberra.edu.au/pub/samba/samba.html includes:
+http://samba.anu.edu.au/samba/ includes:
- Links to man pages and documentation, including this FAQ
diff --git a/docs/faq/Samba-meta-FAQ.sgml b/docs/faq/Samba-meta-FAQ.sgml
index 2b54c6fa0f1..75038f19f53 100644
--- a/docs/faq/Samba-meta-FAQ.sgml
+++ b/docs/faq/Samba-meta-FAQ.sgml
@@ -3,15 +3,17 @@
v 0.1 23 Aug 1997 Dan Shearer
Original Samba-meta-FAQ.sgml from Paul's sambafaq.sgml
v 0.2 25 Aug 1997 Dan
+ v 0.3 7 Oct 1997 Paul
+ Changed samba.canberra refs to samba.anu.../samba/
-->
Samba meta FAQ
-Dan Shearer & Paul Blackman, ictinus@lake.canberra.edu.au
+Dan Shearer & Paul Blackman, ictinus@samba.anu.edu.au
-v 0.1, 23 Aug '97
+v 0.3, 7 Oct '97
This is the meta-Frequently Asked Questions (FAQ) document
for Samba, the free and very popular SMB and CIFS server product. It
@@ -286,7 +288,7 @@ See below for subscription information.
discussion about Samba.
- The WWW site 'SAMBA Web Pages' at includes:
+url="http://samba.anu.edu.au/samba/"> includes:
- Links to man pages and documentation, including this FAQ
diff --git a/docs/faq/Samba-meta-FAQ.txt b/docs/faq/Samba-meta-FAQ.txt
index 967dceac8de..4fb1ed65442 100644
--- a/docs/faq/Samba-meta-FAQ.txt
+++ b/docs/faq/Samba-meta-FAQ.txt
@@ -43,7 +43,7 @@
2.11. Pizza supply details
- 3. About CIFS and SMB
+ 3. About the CIFS and SMB Protocols
3.1. What is the Server Message Block (SMB) Protocol?
@@ -53,7 +53,7 @@
4. Designing A SMB and CIFS Network
- 4.1. Workgroups, Browsing Domains and Authentication Domains
+ 4.1. Workgroups, Domains, Authentication and Browsing
4.1.1. Defining the Terms
@@ -63,19 +63,16 @@
4.2. Authentication Schemes
- 4.2.1. Workgroup Mode Services
- 4.2.2. Windows NT-Style Domain
+ 4.2.1. NIS
- 4.2.3. NIS
+ 4.2.2. Kerberos
- 4.2.4. Kerberos
+ 4.2.3. FTP
- 4.2.5. FTP
+ 4.2.4. Default Server Method
- 4.2.6. Default Server Method
-
- 4.2.7. Client-side Database Only
+ 4.2.5. Client-side Database Only
4.3. Post-Authentication: Netlogon, Logon Scripts, Profiles
@@ -88,47 +85,87 @@
11.. QQuuiicckk RReeffeerreennccee GGuuiiddeess ttoo SSaammbbaa DDooccuummeennttaattiioonn
+
We are endeavouring to provide links here to every major class of
information about Samba or things related to Samba. We cannot list
every document, but we are aiming for all documents to be at most two
referrals from those listed here. This needs constant maintaining, so
please send the author your feedback.
+
11..11.. SSaammbbaa ffoorr tthhee IImmppaattiieenntt
+
You know you should read the documentation but can't wait to start?
What you need to do then is follow the instructions in the following
- documents, in order. This should be enough to get a _s_i_m_p_l_e site going
- quickly. If you have any problems at all, refer back to this section
- and do some more reading.
-
- 1. Getting Samba: ``Download Instructions''
-
- 2. Installing Samba: making sure the binaries are in place and work.
- At the moment there are two kinds of Samba server installs: Unix or
- close relative and Others . Do not forget to
-
- 3. Debug sequence: If you think you have completed the previous step
- and things aren't working properly work through the diagnosis
- recipe.
-
- 4. Exporting files to SMB clients: You should read the manual pages
- for smb.conf, but here is a quick answer guide.
-
- 5. Controlling user access: the quickest and dirtiest way of sharing
- resources is to use ``share level security.'' If you want to spend
- more time and have a proper username and password database you must
- read the paragraph on ``domain mode security.'' If you want
- encryption (eg you are using Windows NT clients) follow the SMB
- encryption instructions.
- 6. Browsing: if you are happy to type in "\samba-serverrename" at the
- client end then do not read any further. Otherwise you need to
- understand the ``browsing terminoligy'' and read .
-
- 7. Printing: See the printing quick answer guide.
+ documents in the order given. This should be enough to get a fairly
+ simple site going quickly. If you have any problems, refer back to
+ this meta-FAQ and follow the links to find more reading material.
+
+
+
+ GGeettttiinngg SSaammbbaa::
+ The fastest way to get Samba going is and install it is to have
+ an operating system for which the Samba team has put together an
+ installation package. To see if your OS is included have a look
+ at the directory /pub/samba/Binary_Packages/"OS_Vendor" on your
+ nearest mirror site <../MIRRORS>. If it is included follow the
+ installation instructions in the README file there and then do
+ some ``basic testing''. If you are not so fortunate, follow the
+ normal ``download instructions'' and then continue with
+ ``building and installing Samba''.
+
+
+ BBuuiillddiinngg aanndd IInnssttaalllliinngg SSaammbbaa::
+ At the moment there are two kinds of Samba server installs
+ besides the prepackaged binaries mentioned in the previous step.
+ You need to decide if you have a Unix or close relative
+ <../UNIX_INSTALL.txt> or other supported operating system
+ .
+
+
+ BBaassiicc TTeessttiinngg::
+ Try to connect using the supplied smbclient command-line
+ program. You need to know the IP hostname of your server. A
+ service name must be defined in smb.conf, as given in the
+ examples (under many operating systems if there is a homes
+ service you can just use a valid username.) Then type smbclient
+ \hostnamevicename Under most Unixes you will need to put the
+ parameters within quotation marks. If this works, try connecting
+ from one of the SMB clients you were planning to use with Samba.
+
+
+ DDeebbuugg sseeqquueennccee::
+ If you think you have completed the previous step and things
+ aren't working properly work through the diagnosis recipe.
+ <../DIAGNOSIS.txt>
+
+
+ EExxppoorrttiinngg ffiilleess ttoo SSMMBB cclliieennttss::
+ You should read the manual pages for smb.conf, but here is a
+ quick answer guide.
+
+
+ CCoonnttrroolllliinngg uusseerr aacccceessss::
+ the quickest and dirtiest way of sharing resources is to use
+ ``share level security.'' If you want to spend more time and
+ have a proper username and password database you must read the
+ paragraph on ``domain mode security.'' If you want encryption
+ (eg you are using Windows NT clients) follow the SMB encryption
+ instructions.
+
+
+ BBrroowwssiinngg::
+ if you are happy to type in "\samba-serverrename" at the client
+ end then do not read any further. Otherwise you need to
+ understand the ``browsing terminology'' and read .
+
+
+ PPrriinnttiinngg::
+ See the printing quick answer guide.
+
If you have got everything working to this point, you can expect Samba
to be stable and secure: these are its greatest strengths. However
@@ -138,8 +175,11 @@
so on are all covered either in this document or in those it refers
to.
+
11..22.. AAllll SSaammbbaa DDooccuummeennttaattiioonn
+
+
+o Meta-FAQ. This is the mother of all documents, and is the one you
are reading now. The latest version is always at
but there is probably a much
@@ -151,27 +191,31 @@
from...)
+o is the best starting point for information
- about client-side issues, includes a list of all clients that work
- with Samba.
+ about client-side issues, includes a list of all clients that are
+ known to work with Samba.
- +o contains descriptions of and links to all
- the Samba manual pages, in Unix man and postscript format.
+ +o manual pages contains descriptions of and
+ links to all the Samba manual pages, in Unix man and postscript
+ format.
+o has descriptions of and links to a large
number of text files have been contributed to samba covering many
- topics. These are gradually being absorbed into the FAQs and HOWTOS
+ topics. These are gradually being absorbed into the FAQs and HOWTOs
but in the meantime you might find helpful answers here.
+o
+
22.. GGeenneerraall IInnffoorrmmaattiioonn
+
All about Samba - what it is, how to get it, related sources of
- information, how to understand the version numbering scheme, pizza
- details
+ information, how to understand the numbering scheme, pizza details.
+
22..11.. WWhhaatt iiss SSaammbbaa??
+
Samba is a suite of programs which work together to allow clients to
access to a server's filespace and printers via the SMB (Server
Message Block) and CIFS (Common Internet Filesystem) protocols.
@@ -181,6 +225,7 @@
behave much like a LAN Server, Windows NT Server or Pathworks machine,
only with added functionality and flexibility designed to make life
easier for administrators.
+
This means that using Samba you can share a server's disks and
printers to many sorts of network clients, including Lan Manager,
Windows for Workgroups, Windows NT, Linux, OS/2, and AIX. There is
@@ -188,6 +233,10 @@
which gives a user on the server an ftp-like interface to access
filespace and printers on any other SMB/CIFS servers.
+ SMB has been implemented over many protocols, including XNS, NBT, IPX,
+ NetBEUI and TCP/IP. Samba only uses TCP/IP. This is not likely to
+ change although there have been some requests for NetBEUI support.
+
Many users report that compared to other SMB implementations Samba is
more stable, faster, and compatible with more clients. Administrators
of some large installations say that Samba is the only SMB server
@@ -206,16 +255,19 @@
versions incorporate much effort by many net.helpers. The man pages
and this FAQ were originally written by Karl Auer.
+
22..22.. WWhhaatt iiss tthhee ccuurrrreenntt vveerrssiioonn ooff SSaammbbaa??
+
At time of writing, the current version was 1.9.17. If you want to be
sure check the bottom of the change-log file.
-
For more information see ``What do the version numbers mean?''
+
22..33.. WWhheerree ccaann II ggeett iitt??
+
The Samba suite is available via anonymous ftp from samba.anu.edu.au
and many mirror <../MIRRORS> sites. You will get much faster
performance if you use a mirror site. The latest and greatest versions
@@ -235,8 +287,18 @@
binaries for that platform. The VMS, OS/2, Netware and Amiga and other
ports typically have binaries made available.
+ A special case is vendor-provided binary packages. Samba binaries and
+ default configuration files are put into packages for a specific
+ operating system. RedHat Linux and Sun Solaris (Sparc and x86) is
+ already included, and others such as OS/2 may follow. All packages are
+ in the directory:
+
+ /pub/samba/Binary_Packages/"OS_Vendor"
+
+
22..44.. WWhhaatt ddoo tthhee vveerrssiioonn nnuummbbeerrss mmeeaann??
+
It is not recommended that you run a version of Samba with the word
"alpha" in its name unless you know what you are doing and are willing
to do some debugging. Many, many people just get the latest
@@ -248,6 +310,7 @@
How the scheme works:
+
1. When major changes are made the version number is increased. For
example, the transition from 1.9.16 to 1.9.17. However, this
version number will not appear immediately and people should
@@ -269,6 +332,7 @@
So the progression goes:
+
1.9.16p10 (production)
1.9.16p11 (production)
1.9.17alpha1 (test sites only)
@@ -277,24 +341,30 @@
1.9.17 (production)
1.9.17p1 (production)
+
+
The above system means that whenever someone looks at the samba ftp
site they will be able to grab the highest numbered release without an
alpha in the name and be sure of getting the current recommended
version.
+
22..55.. WWhheerree ccaann II ggoo ffoorr ffuurrtthheerr iinnffoorrmmaattiioonn??
+
There are a number of places to look for more information on Samba,
including:
+
+o Two mailing lists devoted to discussion of Samba-related matters.
See below for subscription information.
+o The newsgroup comp.protocols.smb, which has a great deal of
discussion about Samba.
- +o The WWW site 'SAMBA Web Pages' at
- includes:
+ +o The WWW site 'SAMBA Web Pages' at
+ includes:
+
+o Links to man pages and documentation, including this FAQ
@@ -306,14 +376,22 @@
+o This FAQ and the rest in its family
+
+
22..66.. HHooww ddoo II ssuubbssccrriibbee ttoo tthhee SSaammbbaa MMaaiilliinngg LLiissttss??
+
Send email to listproc@samba.anu.edu.au. Make sure the subject line is
blank, and include the following two lines in the body of the message:
+
+
subscribe samba Firstname Lastname
subscribe samba-announce Firstname Lastname
+
+
+
Obviously you should substitute YOUR first name for "Firstname" and
YOUR last name for "Lastname"! Try not to send any signature, it
sometimes confuses the list processor.
@@ -327,20 +405,29 @@
listproc@samba.anu.edu.au. Make sure the subject line is blank, and
include the following two lines in the body of the message:
+
+
unsubscribe samba
unsubscribe samba-announce
+
+
+
The FFrroomm:: line in your message _M_U_S_T be the same address you used when
you subscribed.
+
22..77.. SSoommeetthhiinngg''ss ggoonnee wwrroonngg -- wwhhaatt sshhoouulldd II ddoo??
+
## ****** IIMMPPOORRTTAANNTT!! ****** ##
+
DO NOT post messages on mailing lists or in newsgroups until you have
carried out the first three steps given here!
- 1. See if there are any likely looking entries in this FAQ! If you
+
+ 1. See if there are any likely looking entries in this FAQ! If you
have just installed Samba, have you run through the checklist in
DIAGNOSIS.txt ? It
can save you a lot of time and effort. DIAGNOSIS.txt can also be
@@ -370,8 +457,12 @@
succinct description of the symptom, the problem and the solution, so
that an explanation can be incorporated into the next version.
+
+
+
22..88.. HHooww ddoo II ssuubbmmiitt ppaattcchheess oorr bbuugg rreeppoorrttss??
+
If you make changes to the source code, _p_l_e_a_s_e submit these patches so
that everyone else gets the benefit of your work. This is one of the
most important aspects to the maintainence of Samba. Send all patches
@@ -412,6 +503,7 @@
Some extras :
+
+o what you did and what happened
+o relevant parts of a debugging output file with debuglevel higher.
@@ -420,8 +512,10 @@
+o anything else you think is useful to trace down the bug
+
22..99.. WWhhaatt iiff II hhaavvee aann UURRGGEENNTT mmeessssaaggee ffoorr tthhee ddeevveellooppeerrss??
+
If you have spotted something very serious and believe that it is
important to contact the developers quickly send a message to samba-
urgent@samba.anu.edu.au. This will be processed more quickly than mail
@@ -434,21 +528,25 @@
22..1100.. WWhhaatt iiff II nneeeedd ppaaiidd--ffoorr ssuuppppoorrtt??
+
Samba has a large network of consultants who provide Samba support on
a commercial basis. The list is included in the package in
- Support.txt, and the latest version will always be on the main samba
- ftp site. Any company in the world can request that the samba team
- include their details in Support.txt so we can give no guarantee of
- their services.
+ <../Support.txt>, and the latest version will always be on the main
+ samba ftp site. Any company in the world can request that the samba
+ team include their details in Support.txt so we can give no guarantee
+ of their services.
+
22..1111.. PPiizzzzaa ssuuppppllyy ddeettaaiillss
+
Those who have registered in the Samba survey as "Pizza Factory" will
already know this, but the rest may need some help. Andrew doesn't ask
for payment, but he does appreciate it when people give him pizza.
This calls for a little organisation when the pizza donor is twenty
thousand kilometres away, but it has been done.
+
1. Ring up your local branch of an international pizza chain and see
if they honour their vouchers internationally. Pizza Hut do, which
is how the entire Canberra Linux Users Group got to eat pizza one
@@ -468,7 +566,10 @@
will probably get stuck in customs or torn apart by hungry sniffer
dogs but it will have been a noble gesture.
- 33.. AAbboouutt CCIIFFSS aanndd SSMMBB
+
+ 33.. AAbboouutt tthhee CCIIFFSS aanndd SSMMBB PPrroottooccoollss
+
+
33..11.. WWhhaatt iiss tthhee SSeerrvveerr MMeessssaaggee BBlloocckk ((SSMMBB)) PPrroottooccooll??
@@ -493,6 +594,7 @@
implement more and more of these protocols. Samba began to take a
significant share of the SMB server market.
+
33..22.. WWhhaatt iiss tthhee CCoommmmoonn IInntteerrnneett FFiilleessyysstteemm ((CCIIFFSS))??
The initial pressure for Microsoft to document their current SMB
@@ -516,6 +618,7 @@
The following is taken from
+
CIFS defines a standard remote file system access protocol for use
over the Internet, enabling groups of users to work together and
share documents across the Internet or within their corporate
@@ -526,6 +629,8 @@
users can open and share remote files on the Internet without having
to install new software or change the way they work."
+
+
If you consider CIFS as a backwardsly-compatible refinement of SMB
that will work reasonably efficiently over the Internet you won't be
too far wrong.
@@ -537,6 +642,7 @@
reason why a site shouldn't conduct all its file and printer sharing
with CIFS and yet have no Microsoft products at all.
+
33..33.. WWhhaatt iiss BBrroowwssiinngg??
The term "Browsing" causes a lot of confusion. It is the part of the
@@ -549,11 +655,16 @@
subject for debate. Look at the CIFS list archives to see what the
experts think.
+
+
+
44.. DDeessiiggnniinngg AA SSMMBB aanndd CCIIFFSS NNeettwwoorrkk
+
The big issues for installing any network of LAN or WAN file and print
servers are
+
+o How and where usernames, passwords and other security information
is stored
@@ -562,6 +673,7 @@
+o What protocols the clients can converse with
+
If you buy Netware, Windows NT or just about any other LAN fileserver
product you are expected to lock yourself into the product's preferred
answers to these questions. This tendancy is restrictive and often
@@ -573,65 +685,103 @@
administators, which means allowing as many combinations of clients,
servers, operating systems and protocols as possible.
- 44..11.. WWoorrkkggrroouuppss,, BBrroowwssiinngg DDoommaaiinnss aanndd AAuutthheennttiiccaattiioonn DDoommaaiinnss
- The concepts of a Workgroup and a Domain are fundamental to SMB
- networking. Although Microsoft integrates Workgroups and Domains
- tightly with their authentication procedures there is no reason why
- this has to be so in an SMB network. Groups of SMB machines can work
- together just as well with Unix or OS/2 Samba servers as they can with
- Windows NT servers, even though the password storage and access
- methods are totally different.
+ 44..11.. WWoorrkkggrroouuppss,, DDoommaaiinnss,, AAuutthheennttiiccaattiioonn aanndd BBrroowwssiinngg
+
+
+ From the point of view of networking implementation, Domains and
+ Workgroups are _e_x_a_c_t_l_y the same, except for the client logon sequence.
+ Some kind of distributed authentication database is associated with a
+ domain (there are quite a few choices) and this adds so much
+ flexibility that many people think of a domain as a completely
+ different entity to a workgroup. From Samba's point of view a client
+ connecting to a service presents an authentication token, and it if it
+ is valid they have access. Samba does not care what mechanism was used
+ to generate that token in the first place.
+
+ The SMB client logging on to a domain has an expectation that every
+ other server in the domain should accept the same authentication
+ information. However the network browsing functionality of domains
+ and workgroups is identical and is explained in <../BROWSING.txt>.
+
+ There are some implementation differences: Windows 95 can be a member
+ of both a workgroup and a domain, but Windows NT cannot. Windows 95
+ also has the concept of an "alternative workgroup". Samba can only be
+ a member of a single workgroup or domain, although this is due to
+ change with a future version when nmbd will be split into two daemons,
+ one for WINS and the other for browsing ( <../NetBIOS.txt> explains
+ what WINS is.)
+
44..11..11.. DDeeffiinniinngg tthhee TTeerrmmss
- A Workgroup (or Browsing Domain) is collection of machines that
- maintain a common database contianing information about their shared
- resources. They do not necessarily have any security information in
- common. The database is dynamic, modified as servers come and go on
- the network and as resources are added or deleted. The term "browsing"
- refers to a user accessing the database via whatever interface the
- client provides. SMB servers agree between themselves as to which ones
- will maintain the browsing database. Workgroups can be anywhere on a
- connected TCP/IP network, including on different subnets or anywhere
- on the Interet. This is a very tricky part of SMB to implement.
- Due to the convoluted history of SMB there is now conflicting
- terminology describing Domains and Workgroups. "Domain" is used in the
- browsing specifications to define that group of servers and clients
- who share a common name and a common browsing database. The following
- are used exclusively in the context of Workgroup browsing:
- +o Domain Master Browser
- +o Local Master Browser
+ WWoorrkkggrroouupp
+ means a collection of machines that maintain a common browsing
+ database containing information about their shared resources.
+ They do not necessarily have any security information in common
+ (if they do, it gets called a Domain.) The browsing database is
+ dynamic, modified as servers come and go on the network and as
+ resources are added or deleted. The term "browsing" refers to a
+ user accessing the database via whatever interface the client
+ provides, eg the OS/2 Workplace Shell or Windows 95 Explorer.
+ SMB servers agree between themselves as to which ones will
+ maintain the browsing database. Workgroups can be anywhere on a
+ connected TCP/IP network, including on different subnets or even
+ on the Interet. This is a very tricky part of SMB to implement.
+
- Alternative terms include confusing variations such as "Browse
- Master", and "Master Browser" which we are trying to eliminate from
- the Samba documentation. We are moving to the use of "Browsing Domain"
- wherever the word "Domain" occurs in a workgroup context. Ideally
- "Workgroup" would also be replaced by Browsing Domain but it is very
- widely used terminology.
+ MMaasstteerr BBrroowwsseerrss
+ are machines which holds the master browsing database for a
+ workgroup or domain. There are two kinds of Master Browser:
- Unfortunately the group of machines which use the the Microsoft method
- of sharing authentication information (but not any of the many other
- methods) is also called a Domain. As explained elsewhere Microsoft are
- not making this protocol public and The following are used exclusively
- in the context of Microsoft Authentication domains:
- +o Primary Domain Controller
+ +o Domain Master Browser, which holds the master browsing
+ information for an entire domain, which may well cross multiple
+ TCP/IP subnets.
- +o Backup Domain Controller
+ +o Local Master Browser, which holds the master browsing database
+ for a particular subnet and communicates with the Domain Master
+ Browser to get information on other subnets.
+
+ Subnets are differentiated because browsing is based on
+ broadcasts, and broadcasts do not pass through routers. Subnets
+ are not routed: while it is possible to have more than one
+ subnet on a single network segment this is regarded as very bad
+ practice.
+
+ Master Browsers (both Domain and Local) are elected dynamically
+ according to an algorithm which is supposed to take into account
+ the machine's ability to sustain the browsing load. Samba can be
+ configured to always act as a master browser, ie it always wins
+ elections under all circumstances, even against systems such as
+ a Windows NT Primary Domain Controller which themselves expect
+ to win.
+
+ There are also Backup Browsers which are promoted to Master
+ Browsers in the event of a Master Browser disappearing from the
+ network.
+
+ Alternative terms include confusing variations such as "Browse
+ Master", and "Master Browser" which we are trying to eliminate
+ from the Samba documentation.
+
+
+ DDoommaaiinn CCoonnttrroolllleerr
+ is a term which comes from the Microsoft and IBM etc
+ implementation of the LAN Manager protocols. It is tied to
+ authentication. There are other ways of doing domain
+ authentication, but the Windows NT method has a large market
+ share. The general issues are discussed in <../DOMAIN.txt> and
+ a Windows NT-specific discussion is in <../DOMAIN_CONTROL.txt>.
- +o Domain Logon
- These terms can be very confusing, and so in the Samba documentation
- we are moving to the term "Authentication Domain" wherever Domain is
- used in this sense. As a final touch of irony, all Authentication
- Domains are also Browsing Domains.
44..11..22.. SShhaarreelleevveell ((WWoorrkkggrroouupp)) SSeeccuurriittyy SSeerrvviicceess
+
With the Samba setting "security = SHARE", all shared resources
information about what password is associated with them but only hints
as to what usernames might be valid (the hint can be 'all users', in
@@ -643,16 +793,20 @@
authentication infrastructure present or requiring them to do more
than fill in a dialogue box.
+
44..11..33.. AAuutthheennttiiccaattiioonn DDoommaaiinn MMooddee SSeerrvviicceess
+
With the Samba settings "security = USER" or "security = SERVER"
accesses to all resources are checked for username/password pair
- matches in a more rigorous manner. This has the effect of emulating a
- Microsoft Authentication Domain. Whether or not an Authentication
- Domain is involved depends on how the network has been designed.
+ matches in a more rigorous manner. To the client, this has the effect
+ of emulating a Microsoft Domain. The client is not concerned whether
+ or not Samba looks up a Windows NT SAM or does it in some other way.
+
44..22.. AAuutthheennttiiccaattiioonn SScchheemmeess
+
In the simple case authentication information is stored on a single
server and the user types a password on connecting for the first time.
However client operating systems often require a password before they
@@ -661,7 +815,8 @@
different contexts just does not work. Some kind of distributed
authentication database is needed. It must cope with password changes
and provide for assigning groups of users the same level of access
- permissions.
+ permissions. This is why Samba installations often choose to implement
+ a Domain model straight away.
Authentication decisions are some of the biggest in designing a
network. Are you going to use a scheme native to the client operating
@@ -671,29 +826,49 @@
setups would be appreciated. refer to server FAQ for "passwd chat"
passwd program password server etc etc...
- 44..22..11.. WWoorrkkggrroouupp MMooddee SSeerrvviicceess
- etc etc
+ 44..22..11.. NNIISS
+
+
+ For Windows 95, Windows for Workgroups and most other clients Samba
+ can be a domain controller and share the password database via NIS
+ transparently. Windows NT is different. Free NIS NT client
+
+
+
+ 44..22..22.. KKeerrbbeerrooss
+
+
+ Kerberos for US users only: Kerberos overview
+ Download
+ Kerberos
+
+
+ 44..22..33.. FFTTPP
- 44..22..22.. WWiinnddoowwss NNTT--SSttyyllee DDoommaaiinn
- Samba compiled with libdes - enabling encrypted passwords security =
- server
+ Other NT w/s logon hack via NT
- 44..22..33.. NNIISS
- 44..22..44.. KKeerrbbeerrooss
+ 44..22..44.. DDeeffaauulltt SSeerrvveerr MMeetthhoodd
- 44..22..55.. FFTTPP
- 44..22..66.. DDeeffaauulltt SSeerrvveerr MMeetthhoodd
- 44..22..77.. CClliieenntt--ssiiddee DDaattaabbaassee OOnnllyy
+
+
+ 44..22..55.. CClliieenntt--ssiiddee DDaattaabbaassee OOnnllyy
+
+
44..33.. PPoosstt--AAuutthheennttiiccaattiioonn:: NNeettllooggoonn,, LLooggoonn SSccrriippttss,, PPrrooffiilleess
+
+ See <../DOMAIN.txt>
+
+
55.. CCrroossss--PPrroottooccooll FFiillee SShhaarriinngg
+
Samba is an important tool for...
It is possible to...
@@ -710,10 +885,40 @@
packages, Samba, and Linux (and other UNIX-based systems) see
3.5) Sniffing your nework
+
+
66.. MMiisscceellllaanneeoouuss
+
66..11.. IIss SSaammbbaa YYeeaarr 22000000 ccoommpplliiaanntt??
+
The CIFS protocol that Samba implements negotiates times in various
formats, all of which are able to cope with dates beyond 2000.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/faq/sambafaq-1.html b/docs/faq/sambafaq-1.html
index 4b9e589e843..c010e50e011 100644
--- a/docs/faq/sambafaq-1.html
+++ b/docs/faq/sambafaq-1.html
@@ -197,7 +197,7 @@ There are a number of places to look for more information on Samba, including:
- Two mailing lists devoted to discussion of Samba-related matters.
- The newsgroup, comp.protocols.smb, which has a great deal of discussion on Samba.
- The WWW site 'SAMBA Web Pages' at
-http://samba.canberra.edu.au/pub/samba/samba.html includes:
+http://samba.edu.au/samba/ includes:
- Links to man pages and documentation, including this FAQ
- A comprehensive survey of Samba users.
diff --git a/docs/faq/sambafaq-3.html b/docs/faq/sambafaq-3.html
index 8b24de54f23..1b5dcf4d9aa 100644
--- a/docs/faq/sambafaq-3.html
+++ b/docs/faq/sambafaq-3.html
@@ -76,7 +76,7 @@ To syncronize your PC's clock with your Samba server:
- Add timesync.pif to your 'Start Up' group/folder
- Open the properties dialog box for the program/icon
- Make sure the 'Run Minimized' option is set in program 'Properties'
diff --git a/docs/faq/sambafaq.sgml b/docs/faq/sambafaq.sgml
index 951ad822edb..d306881b56b 100644
--- a/docs/faq/sambafaq.sgml
+++ b/docs/faq/sambafaq.sgml
@@ -9,15 +9,17 @@
9 June 1997 Paul
Lots of changes, added doco list, updated compatible systems list
added NT SP3 entry, added Year 2000 entry, Getting ready for 1.9.17
+ v 0.8 7th Oct 97 Paul
+ changed samba.canberra entries to samba.anu.../samba/
-->
Samba FAQ
-Paul Blackman, ictinus@lake.canberra.edu.au
+Paul Blackman, ictinus@samba.anu.edu.au
-v 0.7, June '97
+v 0.8, June '97
This is the Frequently Asked Questions (FAQ) document for
Samba, the free and very popular SMB server product. An SMB server
@@ -191,7 +193,7 @@ There are a number of places to look for more information on Samba, including:
- Two mailing lists devoted to discussion of Samba-related matters.
- The newsgroup, comp.protocols.smb, which has a great deal of discussion on Samba.
-
- The WWW site 'SAMBA Web Pages' at includes:
+
- The WWW site 'SAMBA Web Pages' at includes:
- Links to man pages and documentation, including this FAQ
- A comprehensive survey of Samba users.
@@ -562,7 +564,8 @@ To syncronize your PC's clock with your Samba server:
- Copy timesync.pif to your windows directory
- timesync.pif can be found at:
-
+
- Add timesync.pif to your 'Start Up' group/folder
- Open the properties dialog box for the program/icon
- Make sure the 'Run Minimized' option is set in program 'Properties'
diff --git a/docs/faq/sambafaq.txt b/docs/faq/sambafaq.txt
index e7f5f32a20d..49cfa479fe9 100644
--- a/docs/faq/sambafaq.txt
+++ b/docs/faq/sambafaq.txt
@@ -92,7 +92,7 @@
5.1. Is Samba Year 2000 compliant?
______________________________________________________________________
- 1. General Information
+ 11.. GGeenneerraall IInnffoorrmmaattiioonn
@@ -101,7 +101,7 @@
details
- 1.1. What is Samba?
+ 11..11.. WWhhaatt iiss SSaammbbaa??
Samba is a suite of programs which work together to allow clients to
@@ -122,30 +122,30 @@
The components of the suite are (in summary):
- o smbd, the SMB server. This handles actual connections from clients,
+ +o ssmmbbdd, the SMB server. This handles actual connections from clients,
doing all the file, permission and username work
- o nmbd, the Netbios name server, which helps clients locate servers,
+ +o nnmmbbdd, the Netbios name server, which helps clients locate servers,
doing the browsing work and managing domains as this capability is
being built into Samba
- o smbclient, the Unix-hosted client program
+ +o ssmmbbcclliieenntt, the Unix-hosted client program
- o smbrun, a little 'glue' program to help the server run external
+ +o ssmmbbrruunn, a little 'glue' program to help the server run external
programs
- o testprns, a program to test server access to printers
+ +o tteessttpprrnnss, a program to test server access to printers
- o testparms, a program to test the Samba configuration file for
+ +o tteessttppaarrmmss, a program to test the Samba configuration file for
correctness
- o smb.conf, the Samba configuration file
+ +o ssmmbb..ccoonnff, the Samba configuration file
- o smbprint, a sample script to allow a Unix host to use smbclient to
+ +o ssmmbbpprriinntt, a sample script to allow a Unix host to use smbclient to
print to an SMB server
- o Documentation! DON'T neglect to read it - you will save a great
+ +o DDooccuummeennttaattiioonn!! DON'T neglect to read it - you will save a great
deal of time!
The suite is supplied with full source (of course!) and is GPLed.
@@ -155,7 +155,7 @@
and this FAQ were originally written by Karl Auer.
- 1.2. What is the current version of Samba?
+ 11..22.. WWhhaatt iiss tthhee ccuurrrreenntt vveerrssiioonn ooff SSaammbbaa??
At time of writing, the current version was 1.9.17. If you want to be
@@ -165,7 +165,7 @@
For more information see ``What do the version numbers mean?''
- 1.3. Where can I get it?
+ 11..33.. WWhheerree ccaann II ggeett iitt??
The Samba suite is available via anonymous ftp from samba.anu.edu.au.
@@ -185,7 +185,7 @@
do contain Samba binaries for that platform.
- 1.4. What do the version numbers mean?
+ 11..44.. WWhhaatt ddoo tthhee vveerrssiioonn nnuummbbeerrss mmeeaann??
It is not recommended that you run a version of Samba with the word
@@ -234,7 +234,7 @@
sion.
- 1.5. What platforms are supported?
+ 11..55.. WWhhaatt ppllaattffoorrmmss aarree ssuuppppoorrtteedd??
Many different platforms have run Samba successfully. The platforms
@@ -242,188 +242,188 @@
At time of writing, the Makefile claimed support for:
- o A/UX 3.0
+ +o A/UX 3.0
- o AIX
+ +o AIX
- o Altos Series 386/1000
+ +o Altos Series 386/1000
- o Amiga
+ +o Amiga
- o Apollo Domain/OS sr10.3
+ +o Apollo Domain/OS sr10.3
- o BSDI
+ +o BSDI
- o B.O.S. (Bull Operating System)
+ +o B.O.S. (Bull Operating System)
- o Cray, Unicos 8.0
+ +o Cray, Unicos 8.0
- o Convex
+ +o Convex
- o DGUX.
+ +o DGUX.
- o DNIX.
+ +o DNIX.
- o FreeBSD
+ +o FreeBSD
- o HP-UX
+ +o HP-UX
- o Intergraph.
+ +o Intergraph.
- o Linux with/without shadow passwords and quota
+ +o Linux with/without shadow passwords and quota
- o LYNX 2.3.0
+ +o LYNX 2.3.0
- o MachTen (a unix like system for Macintoshes)
+ +o MachTen (a unix like system for Macintoshes)
- o Motorola 88xxx/9xx range of machines
+ +o Motorola 88xxx/9xx range of machines
- o NetBSD
+ +o NetBSD
- o NEXTSTEP Release 2.X, 3.0 and greater (including OPENSTEP for
+ +o NEXTSTEP Release 2.X, 3.0 and greater (including OPENSTEP for
Mach).
- o OS/2 using EMX 0.9b
+ +o OS/2 using EMX 0.9b
- o OSF1
+ +o OSF1
- o QNX 4.22
+ +o QNX 4.22
- o RiscIX.
+ +o RiscIX.
- o RISCOs 5.0B
+ +o RISCOs 5.0B
- o SEQUENT.
+ +o SEQUENT.
- o SCO (including: 3.2v2, European dist., OpenServer 5)
+ +o SCO (including: 3.2v2, European dist., OpenServer 5)
- o SGI.
+ +o SGI.
- o SMP_DC.OSx v1.1-94c079 on Pyramid S series
+ +o SMP_DC.OSx v1.1-94c079 on Pyramid S series
- o SONY NEWS, NEWS-OS (4.2.x and 6.1.x)
+ +o SONY NEWS, NEWS-OS (4.2.x and 6.1.x)
- o SUNOS 4
+ +o SUNOS 4
- o SUNOS 5.2, 5.3, and 5.4 (Solaris 2.2, 2.3, and '2.4 and later')
+ +o SUNOS 5.2, 5.3, and 5.4 (Solaris 2.2, 2.3, and '2.4 and later')
- o Sunsoft ISC SVR3V4
+ +o Sunsoft ISC SVR3V4
- o SVR4
+ +o SVR4
- o System V with some berkely extensions (Motorola 88k R32V3.2).
+ +o System V with some berkely extensions (Motorola 88k R32V3.2).
- o ULTRIX.
+ +o ULTRIX.
- o UNIXWARE
+ +o UNIXWARE
- o UXP/DS
+ +o UXP/DS
- 1.6. How can I find out more about Samba?
+ 11..66.. HHooww ccaann II ffiinndd oouutt mmoorree aabboouutt SSaammbbaa??
There are a number of places to look for more information on Samba,
including:
- o Two mailing lists devoted to discussion of Samba-related matters.
+ +o Two mailing lists devoted to discussion of Samba-related matters.
- o The newsgroup, comp.protocols.smb, which has a great deal of
+ +o The newsgroup, comp.protocols.smb, which has a great deal of
discussion on Samba.
- o The WWW site 'SAMBA Web Pages' at
- includes:
+ +o The WWW site 'SAMBA Web Pages' at
+ includes:
- o Links to man pages and documentation, including this FAQ
+ +o Links to man pages and documentation, including this FAQ
- o A comprehensive survey of Samba users.
+ +o A comprehensive survey of Samba users.
- o A searchable hypertext archive of the Samba mailing list.
+ +o A searchable hypertext archive of the Samba mailing list.
- o Links to Samba source code, binaries, and mirrors of both.
+ +o Links to Samba source code, binaries, and mirrors of both.
- o The long list of topic documentation. These files can be found in
+ +o The long list of topic documentation. These files can be found in
the 'docs' directory of the Samba source, or at
- o Application_Serving.txt
+ +o Application_Serving.txt
- o BROWSING.txt
+ +o BROWSING.txt
- o BUGS.txt
+ +o BUGS.txt
- o DIAGNOSIS.txt
+ +o DIAGNOSIS.txt
- o DNIX.txt
+ +o DNIX.txt
- o DOMAIN.txt
+ +o DOMAIN.txt
- o CONTROL.txt
+ +o CONTROL.txt
- o ENCRYPTION.txt
+ +o ENCRYPTION.txt
- o Faxing.txt
+ +o Faxing.txt
- o GOTCHAS.txt
+ +o GOTCHAS.txt
- o HINTS.txt
+ +o HINTS.txt
- o INSTALL.sambatar
+ +o INSTALL.sambatar
- o INSTALL.txt
+ +o INSTALL.txt
- o MIRRORS
+ +o MIRRORS
- o NetBIOS.txt
+ +o NetBIOS.txt
- o OS2.txt
+ +o OS2.txt
- o PROJECTS
+ +o PROJECTS
- o Passwords.txt
+ +o Passwords.txt
- o Printing.txt
+ +o Printing.txt
- o README.DCEDFS
+ +o README.DCEDFS
- o README.OS2
+ +o README.OS2
- o README.jis
+ +o README.jis
- o README.sambatar
+ +o README.sambatar
- o SCO.txt
+ +o SCO.txt
- o SMBTAR.notes
+ +o SMBTAR.notes
- o Speed.txt
+ +o Speed.txt
- o Support.txt
+ +o Support.txt
- o THANKS
+ +o THANKS
- o Tracing.txt
+ +o Tracing.txt
- o SMB.txt
+ +o SMB.txt
- o Warp.txt
+ +o Warp.txt
- o WinNT.txt
+ +o WinNT.txt
- o history
+ +o history
- o level.txt
+ +o level.txt
- o slip.htm
+ +o slip.htm
- 1.7. How do I subscribe to the Samba Mailing Lists?
+ 11..77.. HHooww ddoo II ssuubbssccrriibbee ttoo tthhee SSaammbbaa MMaaiilliinngg LLiissttss??
Send email to listproc@samba.anu.edu.au. Make sure the subject line is
@@ -456,14 +456,14 @@
- The From: line in your message MUST be the same address you used when
+ The FFrroomm:: line in your message _M_U_S_T be the same address you used when
you subscribed.
- 1.8. Something's gone wrong - what should I do?
+ 11..88.. SSoommeetthhiinngg''ss ggoonnee wwrroonngg -- wwhhaatt sshhoouulldd II ddoo??
- # *** IMPORTANT! *** #
+ ## ****** IIMMPPOORRTTAANNTT!! ****** ##
DO NOT post messages on mailing lists or in newsgroups until you have
carried out the first three steps given here!
@@ -501,7 +501,7 @@
Tridgell or any other individual, they may be lost if you do.
- 1.9. Pizza supply details
+ 11..99.. PPiizzzzaa ssuuppppllyy ddeettaaiillss
Those who have registered in the Samba survey as "Pizza Factory" will
@@ -531,11 +531,11 @@
hungry sniffer dogs but it will have been a noble gesture.
- 2. Compiling and installing Samba on a Unix host
+ 22.. CCoommppiilliinngg aanndd iinnssttaalllliinngg SSaammbbaa oonn aa UUnniixx hhoosstt
- 2.1. I can't see the Samba server in any browse lists!
+ 22..11.. II ccaann''tt sseeee tthhee SSaammbbaa sseerrvveerr iinn aannyy bbrroowwssee lliissttss!!
See BROWSING.txt for
@@ -557,14 +557,14 @@
client to client - check your client's documentation.
- 2.2. Some files that I KNOW are on the server doesn't show up when I
- view the files from my client!
+ 22..22.. SSoommee ffiilleess tthhaatt II KKNNOOWW aarree oonn tthhee sseerrvveerr ddooeessnn''tt sshhooww uupp wwhheenn II
+ vviieeww tthhee ffiilleess ffrroomm mmyy cclliieenntt!!
See the next question.
- 2.3. Some files on the server show up with really wierd filenames
- when I view the files from my client!
+ 22..33.. SSoommee ffiilleess oonn tthhee sseerrvveerr sshhooww uupp wwiitthh rreeaallllyy wwiieerrdd ffiilleennaammeess
+ wwhheenn II vviieeww tthhee ffiilleess ffrroomm mmyy cclliieenntt!!
If you check what files are not showing up, you will note that they
@@ -579,7 +579,7 @@
"mangled names = yes".
- 2.4. My client reports "cannot locate specified computer" or similar
+ 22..44.. MMyy cclliieenntt rreeppoorrttss ""ccaannnnoott llooccaattee ssppeecciiffiieedd ccoommppuutteerr"" oorr ssiimmiillaarr
This indicates one of three things: You supplied an incorrect server
@@ -610,8 +610,8 @@
tests :-)
- 2.5. My client reports "cannot locate specified share name" or simi-
- lar
+ 22..55.. MMyy cclliieenntt rreeppoorrttss ""ccaannnnoott llooccaattee ssppeecciiffiieedd sshhaarree nnaammee"" oorr ssiimmii--
+ llaarr
This message indicates that your client CAN locate the specified
@@ -624,19 +624,19 @@
to specify a service name correctly), read on:
- o Many clients cannot accept or use service names longer than eight
+ +o Many clients cannot accept or use service names longer than eight
characters.
- o Many clients cannot accept or use service names containing spaces.
+ +o Many clients cannot accept or use service names containing spaces.
- o Some servers (not Samba though) are case sensitive with service
+ +o Some servers (not Samba though) are case sensitive with service
names.
- o Some clients force service names into upper case.
+ +o Some clients force service names into upper case.
- 2.6. My client reports "cannot find domain controller", "cannot log
- on to the network" or similar
+ 22..66.. MMyy cclliieenntt rreeppoorrttss ""ccaannnnoott ffiinndd ddoommaaiinn ccoonnttrroolllleerr"",, ""ccaannnnoott lloogg
+ oonn ttoo tthhee nneettwwoorrkk"" oorr ssiimmiillaarr
Nothing is wrong - Samba does not implement the primary domain name
@@ -658,7 +658,7 @@
- 2.7. Printing doesn't work :-(
+ 22..77.. PPrriinnttiinngg ddooeessnn''tt wwoorrkk ::--((
Make sure that the specified print command for the service you are
@@ -689,8 +689,8 @@
mechanism.
- 2.8. My programs install on the server OK, but refuse to work prop-
- erly
+ 22..88.. MMyy pprrooggrraammss iinnssttaallll oonn tthhee sseerrvveerr OOKK,, bbuutt rreeffuussee ttoo wwoorrkk pprroopp--
+ eerrllyy
There are numerous possible reasons for this, but one MAJOR
@@ -706,7 +706,7 @@
Tridgell know via email at samba-bugs@samba.anu.edu.au.
- 2.9. My "server string" doesn't seem to be recognised
+ 22..99.. MMyy ""sseerrvveerr ssttrriinngg"" ddooeessnn''tt sseeeemm ttoo bbee rreeccooggnniisseedd
OR My client reports the default setting, eg. "Samba 1.9.15p4",
@@ -719,8 +719,8 @@
the "server string" field of smb.conf, -C for nmbd is now obsolete.
- 2.10. My client reports "This server is not configured to list shared
- resources"
+ 22..1100.. MMyy cclliieenntt rreeppoorrttss ""TThhiiss sseerrvveerr iiss nnoott ccoonnffiigguurreedd ttoo lliisstt sshhaarreedd
+ rreessoouurrcceess""
Your guest account is probably invalid for some reason. Samba uses the
@@ -730,7 +730,7 @@
See also 'guest account' in smb.conf man page.
- 2.11. Log message "you appear to have a trapdoor uid system"
+ 22..1111.. LLoogg mmeessssaaggee ""yyoouu aappppeeaarr ttoo hhaavvee aa ttrraappddoooorr uuiidd ssyysstteemm""
This can have several causes. It might be because you are using a uid
@@ -765,12 +765,12 @@
as uid 65535 will actually run as root. This is not good!
- 3. Common client questions
+ 33.. CCoommmmoonn cclliieenntt qquueessttiioonnss
- 3.1. Are there any Macintosh clients for Samba?
+ 33..11.. AArree tthheerree aannyy MMaacciinnttoosshh cclliieennttss ffoorr SSaammbbaa??
Yes! Thursby now have a CIFS Client / Server called DAVE - see
@@ -790,7 +790,7 @@
Windows users, these packages offer to Macs. For more info on these
packages, Samba, and Linux (and other UNIX-based systems) see
- 3.2. Session request failed (131,130)" error
+ 33..22.. SSeessssiioonn rreeqquueesstt ffaaiilleedd ((113311,,113300))"" eerrrroorr
The following answer is provided by John E. Miller:
@@ -819,26 +819,26 @@
you'd have to use smbclient -iSomeStr otherparms in connecting to it.
- 3.3. How do I synchronise my PC's clock with my Samba server?
+ 33..33.. HHooww ddoo II ssyynncchhrroonniissee mmyy PPCC''ss cclloocckk wwiitthh mmyy SSaammbbaa sseerrvveerr??
To syncronize your PC's clock with your Samba server:
- o Copy timesync.pif to your windows directory
+ +o Copy timesync.pif to your windows directory
- o timesync.pif can be found at:
-
+ +o timesync.pif can be found at:
+
- o Add timesync.pif to your 'Start Up' group/folder
+ +o Add timesync.pif to your 'Start Up' group/folder
- o Open the properties dialog box for the program/icon
+ +o Open the properties dialog box for the program/icon
- o Make sure the 'Run Minimized' option is set in program 'Properties'
+ +o Make sure the 'Run Minimized' option is set in program 'Properties'
- o Change the command line section that reads \sambahost to reflect
+ +o Change the command line section that reads \sambahost to reflect
the name of your server.
- o Close the properties dialog box by choosing 'OK'
+ +o Close the properties dialog box by choosing 'OK'
Each time you start your computer (or login for Win95) your PC will
synchronize its clock with your Samba server.
@@ -858,7 +858,7 @@
as one of the lines in the logon script.
- 3.4. Problems with WinDD, NTrigue, WinCenterPro etc
+ 33..44.. PPrroobblleemmss wwiitthh WWiinnDDDD,, NNTTrriigguuee,, WWiinnCCeenntteerrPPrroo eettcc
All of the above programs are applications that sit on an NT box and
@@ -900,7 +900,7 @@
home directory. Use \serversername instead.
- 3.5. Problem with printers under NT
+ 33..55.. PPrroobblleemm wwiitthh pprriinntteerrss uunnddeerr NNTT
This info from Stefan Hergeth hergeth@f7axp1.informatik.fh-muenchen.de
@@ -929,7 +929,7 @@
try it yet.
- 3.6. Why are my file's timestamps off by an hour, or by a few hours?
+ 33..66.. WWhhyy aarree mmyy ffiillee''ss ttiimmeessttaammppss ooffff bbyy aann hhoouurr,, oorr bbyy aa ffeeww hhoouurrss??
This is from Paul Eggert eggert@twinsun.com.
@@ -973,20 +973,20 @@
where:
- o `Std' is the standard time designation (e.g. `PST').
+ +o `Std' is the standard time designation (e.g. `PST').
- o `Offset' is the number of hours behind UTC (e.g. `8'). Prepend
+ +o `Offset' is the number of hours behind UTC (e.g. `8'). Prepend
a `-' if you are ahead of UTC, and append `:30' if you are at a
half-hour offset. Omit all the remaining items if you do not
use daylight-saving time.
- o `Dst' is the daylight-saving time designation (e.g. `PDT').
+ +o `Dst' is the daylight-saving time designation (e.g. `PDT').
The optional second `Offset' is the number of hours that
daylight-saving time is behind UTC. The default is 1 hour ahead
of standard time.
- o `Date/Time,Date/Time' specify when daylight-saving time starts
+ +o `Date/Time,Date/Time' specify when daylight-saving time starts
and ends. The format for a date is `Mm.n.d', which specifies
the dth day (0 is Sunday) of the nth week of the mth month,
where week 5 means the last such day in the month. The format
@@ -1005,7 +1005,7 @@
Samba server to 1.9.16alpha10 or later.
- 3.7. How do I set the printer driver name correctly?
+ 33..77.. HHooww ddoo II sseett tthhee pprriinntteerr ddrriivveerr nnaammee ccoorrrreeccttllyy??
Question: On NT, I opened "Printer Manager" and "Connect to Printer".
@@ -1050,17 +1050,17 @@
this is effectively what older versions of Samba did, so if that
worked for you then give it a go. If this does work then let us know
- via samba-bugs@samba.anu.edu.au, and we'll make it the default. Currently
- the default is a 0 length string.
+ via samba-bugs@samba.anu.edu.au, and we'll make it the default. Cur-
+ rently the default is a 0 length string.
- 3.8. I've applied NT 4.0 SP3, and now I can't access Samba shares,
- Why?
+ 33..88.. II''vvee aapppplliieedd NNTT 44..00 SSPP33,, aanndd nnooww II ccaann''tt aacccceessss SSaammbbaa sshhaarreess,,
+ WWhhyy??
As of SP3, Microsoft has decided that they will no longer default to
passing clear text passwords over the network. To enable access to
- Samba shares from NT 4.0 SP3, you must do ONE of two things:
+ Samba shares from NT 4.0 SP3, you must do OONNEE of two things:
1. Set the Samba configuration option 'security = user' and implement
all of the stuff detailed in ENCRYPTION.txt
@@ -1071,13 +1071,13 @@
- 4. Specific client application problems
+ 44.. SSppeecciiffiicc cclliieenntt aapppplliiccaattiioonn pprroobblleemmss
- 4.1. MS Office Setup reports "Cannot change properties of 'MSOF-
- FICEUP.INI'"
+ 44..11.. MMSS OOffffiiccee SSeettuupp rreeppoorrttss ""CCaannnnoott cchhaannggee pprrooppeerrttiieess ooff ''MMSSOOFF--
+ FFIICCEEUUPP..IINNII''""
When installing MS Office on a Samba drive for which you have admin
@@ -1093,11 +1093,11 @@
to fix the owner.
- 5. Miscellaneous
+ 55.. MMiisscceellllaanneeoouuss
- 5.1. Is Samba Year 2000 compliant?
+ 55..11.. IIss SSaammbbaa YYeeaarr 22000000 ccoommpplliiaanntt??
The CIFS protocol that Samba implements negotiates times in various
diff --git a/docs/manpages/samba.7 b/docs/manpages/samba.7
index 7e98c850d41..7260cbad396 100644
--- a/docs/manpages/samba.7
+++ b/docs/manpages/samba.7
@@ -65,7 +65,7 @@ the mailing list are given in the README file that comes with Samba.
If you have access to a WWW viewer (such as Netscape or Mosaic) then
you will also find lots of useful information, including back issues
-of the Samba mailing list, at http://samba.canberra.edu.au/pub/samba/
+of the Samba mailing list, at http://samba.anu.edu.au/samba/
.SH AUTHOR
The main author of the Samba suite is Andrew Tridgell. He may be
diff --git a/docs/samba.faq b/docs/samba.faq
deleted file mode 100644
index 19126439500..00000000000
--- a/docs/samba.faq
+++ /dev/null
@@ -1,900 +0,0 @@
-
- Frequently Asked Questions
-
- about the
-
- SAMBA Suite
-
- (FAQ version 1.9.15a, Samba version 1.09.15)
-
--------------------------------------------------------------------------------
-
-This FAQ was originally prepared by Karl Auer and is
-currently maintained by Paul Blackman (ictinus@lake.canberra.edu.au).
-
-As Karl originally said, 'this FAQ was prepared with lots of help from numerous
-net.helpers', and that's the way I'd like to keep it. So if you find anything
-that you think should be in here don't hesitate to contact me.
-
-Thanks to Karl for the work he's done, and continuing thanks to Andrew Tridgell
-for developing Samba.
-
-Note: This FAQ is (and probably always will be) under construction. Some
-sections exist only as optimistic entries in the Contents page.
-
--------------------------------------------------------------------------------
-
-Contents
-
- * SECTION ONE: General information
- All about Samba - what it is, how to get it, related sources of
- information, how to understand the version numbering scheme,
- pizza details
- * SECTION TWO: Compiling and installing Samba on a Unix host
- Common problems that arise when building and installing Samba under
- Unix.
- * SECTION THREE: Common client problems
- Common problems that arise when trying to communicate from a client
- computer to a Samba server. All problems which have symptoms you see
- at the client end will be in this section.
- * SECTION FOUR: Specific client problems
- This section covers problems that are specific to certain clients,
- such as Windows for Workgroups or Windows NT. Please check Section
- Three first!
- * SECTION FIVE: Specific client application problems
- This section covers problems that are specific to certain products,
- such as Windows for Workgroups or Windows NT. Please check Sections
- Three and Four first!
- * SECTION SIX: Miscellaneous
- All the questions that aren't classifiable into any other section.
-
-
-===============================================================================
-SECTION ONE: General information
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 1: What is Samba?
-
-Samba is a suite of programs which work together to allow clients to access
-to a server's filespace and printers via the SMB (Session Message Block)
-protocol. Initially written for Unix, Samba now also runs on Netware, OS/2 and
-AmigaDOS.
-
-In practice, this means that you can redirect disks and printers to Unix disks
-and printers from Lan Manager clients, Windows for Workgroups 3.11 clients,
-Windows NT clients, Linux clients and OS/2 clients. There is also a generic
-Unix client program supplied as part of the suite which allows Unix users to
-use an ftp-like interface to access filespace and printers on any other SMB
-servers. This gives the capability for these operating systems to behave much
-like a LAN Server or Windows NT Server machine, only with added functionality
-and flexibility designed to make life easier for administrators.
-
-The components of the suite are (in summary):
-
- * smbd, the SMB server. This handles actual connections from clients,
- doing all the file, permission and username work
- * nmbd, the Netbios name server, which helps clients locate servers,
- doing the browsing work and managing domains as this capability is
- being built into Samba
- * smbclient, the Unix-hosted client program
- * smbrun, a little 'glue' program to help the server run external
- programs
- * testprns, a program to test server access to printers
- * testparms, a program to test the Samba configuration file for
- correctness
- * smb.conf, the Samba configuration file
- * smbprint, a sample script to allow a Unix host to use smbclient to
- print to an SMB server
- * documentation! DON'T neglect to read it - you will save a great deal
- of time!
-
-The suite is supplied with full source (of course!) and is GPLed.
-
-The primary creator of the Samba suite is Andrew Tridgell. Later versions
-incorporate much effort by many net.helpers. The man pages and this FAQ were
-originally written by Karl Auer.
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 2: What is the current version of Samba?
-
-At time of writing, the current version was 1.9.16. If you want to be sure
-check the bottom of the change-log file.
-(ftp://samba.anu.edu.au/pub/samba/alpha/change-log)
-
-For more information see question 5, "What do the version numbers mean?"
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 3: Where can I get it?
-
-The Samba suite is available via anonymous ftp from samba.anu.edu.au. The
-latest and greatest versions of the suite are in the directory:
-
-/pub/samba/
-
-Development (read "alpha") versions, which are NOT necessarily stable and which
-do NOT necessarily have accurate documentation, are available in the directory:
-
-/pub/samba/alpha
-
-Note that binaries are NOT included in any of the above. Samba is distributed
-ONLY in source form, though binaries may be available from other sites. Recent
-versions of some Linux distributions, for example, do contain Samba binaries
-for that platform.
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 5: What do the version numbers mean?
-
-It is not recommended that you run a version of Samba with the word "alpha"
-in its name unless you know what you are doing and are willing to do some
-debugging. Many, many people just get the latest recommended stable release
-version and are happy. If you are brave, by all means take the plunge and
-help with the testing and development - but don't install it on your
-departmental server. Samba is typically very stable and safe, and this is
-mostly due to the policy of many public releases.
-
-How the scheme works:
-
-1) when major changes are made the version number is increased. For example,
-the transition from 1.9.15 to 1.9.16. However, this version number will not
-appear immediately and people should continue to use 1.9.15 for production
-systems (see next point.)
-
-2) just after major changes are made the software is considered
-unstable, and a series of alpha releases are distributed, for example
-1.9.16alpha1. These are for testing by those who know what they are doing.
-The "alpha" in the filename will hopefully scare off those who are just
-looking for the latest version to install.
-
-3) when Andrew thinks that the alphas have stabilised to the point where he
-would recommend new users install it, he renames it to the same version
-number without the alpha, for example 1.9.16.
-
-4) inevitably bugs are found in the "stable" releases and minor
-patch levels are released which give us the pXX series, for example
-1.9.16p2.
-
-So the progression goes:
-
- 1.9.15p7 (production)
- 1.9.15p8 (production)
- 1.9.16alpha1 (test sites only)
- :
- 1.9.16alpha20 (test sites only)
- 1.9.16 (production)
- 1.9.16p1 (production)
-
-The above system means that whenever someone looks at the samba ftp site
-they will be able to grab the highest numbered release without an
-alpha in the name and be sure of getting the current recommended
-version.
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 4: What platforms are supported?
-
-Many different platforms have run Samba successfully. The platforms most widely
-used and thus best tested are Linux and SunOS.
-
-At time of writing, the Makefile claimed support for:
-
- * SunOS
- * Linux with shadow passwords
- * Linux without shadow passwords
- * SOLARIS
- * SOLARIS 2.2 and above (aka SunOS 5)
- * SVR4
- * ULTRIX
- * OSF1 (alpha only)
- * OSF1 with NIS and Fast Crypt (alpha only)
- * OSF1 V2.0 Enhanced Security (alpha only)
- * AIX
- * BSDI
- * NetBSD
- * NetBSD 1.0
- * SEQUENT
- * HP-UX
- * SGI
- * SGI IRIX 4.x.x
- * SGI IRIX 5.x.x
- * FreeBSD
- * NeXT 3.2 and above
- * NeXT OS 2.x
- * NeXT OS 3.0
- * ISC SVR3V4 (POSIX mode)
- * ISC SVR3V4 (iBCS2 mode)
- * A/UX 3.0
- * SCO with shadow passwords.
- * SCO with shadow passwords, without YP.
- * SCO with TCB passwords
- * SCO 3.2v2 (ODT 1.1) with TCP passwords
- * intergraph
- * DGUX
- * Apollo Domain/OS sr10.3 (BSD4.3)
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 5: How can I find out more about Samba?
-
-There are two mailing lists devoted to discussion of Samba-related matters.
-There is also the newsgroup, comp.protocols.smb, which has a great deal of
-discussion on Samba. There is also a WWW site 'SAMBA Web Pages' at
-http://samba.canberra.edu.au/pub/samba/samba.html, under which there is a
-comprehensive survey of Samba users. Another useful resource is the hypertext
-archive of the Samba mailing list.
-
-Send email to listproc@samba.anu.edu.au. Make sure the subject line is
-blank, and include the following two lines in the body of the message:
-
- subscribe samba Firstname Lastname
- subscribe samba-announce Firstname Lastname
-
-Obviously you should substitute YOUR first name for "Firstname" and YOUR last
-name for "Lastname"! Try not to send any signature stuff, it sometimes confuses
-the list processor.
-
-The samba list is a digest list - every eight hours or so it regurgitates a
-single message containing all the messages that have been received by the list
-since the last time and sends a copy of this message to all subscribers.
-
-If you stop being interested in Samba, please send another email to
-listproc@samba.anu.edu.au. Make sure the subject line is blank, and
-include the following two lines in the body of the message:
-
- unsubscribe samba
- unsubscribe samba-announce
-
-The From: line in your message MUST be the same address you used when you
-subscribed.
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 6: Something's gone wrong - what should I do?
-
-[#] *** IMPORTANT! *** [#]
-DO NOT post messages on mailing lists or in newsgroups until you have carried
-out the first three steps given here!
-
-Firstly, see if there are any likely looking entries in this FAQ! If you have
-just installed Samba, have you run through the checklist in DIAGNOSIS.txt? It
-can save you a lot of time and effort.
-
-Secondly, read the man pages for smbd, nmbd and smb.conf, looking for topics
-that relate to what you are trying to do.
-
-Thirdly, if there is no obvious solution to hand, try to get a look at the log
-files for smbd and/or nmbd for the period during which you were having
-problems. You may need to reconfigure the servers to provide more extensive
-debugging information - usually level 2 or level 3 provide ample debugging
-info. Inspect these logs closely, looking particularly for the string "Error:".
-
-Fourthly, if you still haven't got anywhere, ask the mailing list or newsgroup.
-In general nobody minds answering questions provided you have followed the
-preceding steps. It might be a good idea to scan the archives of the mailing
-list, which are available through the Samba web site described in the previous
-section.
-
-If you successfully solve a problem, please mail the FAQ maintainer a succinct
-description of the symptom, the problem and the solution, so I can incorporate
-it in the next version.
-
-If you make changes to the source code, _please_ submit these patches so that
-everyone else gets the benefit of your work. This is one of the most important
-aspects to the maintainence of Samba. Send all patches to
-samba-bugs@samba.anu.edu.au, not Andrew Tridgell or any other individual and
-not the samba team mailing list.
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* n: Pizza Supply Details
-
-Those who have registered in the Samba survey as "Pizza Factory" will already
-know this, but the rest may need some help. Andrew doesn't ask for payment,
-but he does appreciate it when people give him pizza. This calls for a little
-organisation when the pizza donor is twenty thousand kilometres away, but
-it has been done.
-
-Method 1: Ring up your local branch of an international pizza chain and see if
-they honour their vouchers internationally. Pizza Hut do, which is how the
-entire Canberra Linux Users Group got to eat pizza one night, courtesy of
-someone in the US
-
-Method 2: Ring up a local pizza shop in Canberra and quote a credit card
-number for a certain amount, and tell them that Andrew will be collecting
-it (don't forget to tell him.) One kind soul from Germany did this.
-
-Method 3: Purchase a pizza voucher from your local pizza shop that has no
-international affiliations and send it to Andrew. It is completely useless
-but he can hang it on the wall next to the one he already has from Germany :-)
-
-Method 4: Air freight him a pizza with your favourite regional flavours. It will
-probably get stuck in customs or torn apart by hungry sniffer dogs but it will
-have been a noble gesture.
-
-===============================================================================
-SECTION TWO: Compiling and installing Samba on a Unix host
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-
-===============================================================================
-SECTION THREE: Common client problems
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 1: I can't see the Samba server in any browse lists!
-
-*** Until the FAQ can be updated, please check the file:
-*** ftp://samba.anu.edu.au/pub/samba/docs/BROWSING.txt
-*** for more information on browsing.
-
-If your GUI client does not permit you to select non-browsable servers, you may
-need to do so on the command line. For example, under Lan Manager you might
-connect to the above service as disk drive M: thusly:
-
- net use M: \\mary\fred
-
-The details of how to do this and the specific syntax varies from client to
-client - check your client's documentation.
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 2: Some files that I KNOW are on the server doesn't show up when I view the
- directories from my client!
-
-If you check what files are not showing up, you will note that they are files
-which contain upper case letters or which are otherwise not DOS-compatible (ie,
-they are not legal DOS filenames for some reason).
-
-The Samba server can be configured either to ignore such files completely, or
-to present them to the client in "mangled" form. If you are not seeing the
-files at all, the Samba server has most likely been configured to ignore them.
-Consult the man page smb.conf(5) for details of how to change this - the
-parameter you need to set is "mangled names = yes".
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 3: Some files on the server show up with really wierd filenames when I view
-the directories from my client!
-
-If you check what files are showing up wierd, you will note that they are files
-which contain upper case letters or which are otherwise not DOS-compatible (ie,
-they are not legal DOS filenames for some reason).
-
-The Samba server can be configured either to ignore such files completely, or
-to present them to the client in "mangled" form. If you are seeing strange file
-names, they are most likely "mangled". If you would prefer to have such files
-ignored rather than presented in "mangled" form, consult the man page
-smb.conf(5) for details of how to change the server configuration - the
-parameter you need to set is "mangled names = no".
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 4: My client reports "cannot locate specified computer" or similar.
-
-This indicates one of three things: You supplied an incorrect server name, the
-underlying TCP/IP layer is not working correctly, or the name you specified
-cannot be resolved.
-
-After carefully checking that the name you typed is the name you should have
-typed, try doing things like pinging a host or telnetting to somewhere on your
-network to see if TCP/IP is functioning OK. If it is, the problem is most
-likely name resolution.
-
-If your client has a facility to do so, hardcode a mapping between the hosts IP
-and the name you want to use. For example, with Man Manager or Windows for
-Workgroups you would put a suitable entry in the file LMHOSTS. If this works,
-the problem is in the communication between your client and the netbios name
-server. If it does not work, then there is something fundamental wrong with
-your naming and the solution is beyond the scope of this document.
-
-If you do not have any server on your subnet supplying netbios name resolution,
-hardcoded mappings are your only option. If you DO have a netbios name server
-running (such as the Samba suite's nmbd program), the problem probably lies in
-the way it is set up. Refer to Section Two of this FAQ for more ideas.
-
-By the way, remember to REMOVE the hardcoded mapping before further tests :-)
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 5: My client reports "cannot locate specified share name" or similar.
-
-This message indicates that your client CAN locate the specified server, which
-is a good start, but that it cannot find a service of the name you gave.
-
-The first step is to check the exact name of the service you are trying to
-connect to (consult your system administrator). Assuming it exists and you
-specified it correctly (read your client's doco on how to specify a service
-name correctly), read on:
-
- * Many clients cannot accept or use service names longer than eight
- characters.
- * Many clients cannot accept or use service names containing spaces.
- * Some servers (not Samba though) are case sensitive with service names.
- * Some clients force service names into upper case.
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 6: My client reports "cannot find domain controller", "cannot log on to the
-network" or similar.
-
-Nothing is wrong - Samba does not implement the primary domain name controller
-stuff for several reasons, including the fact that the whole concept of a
-primary domain controller and "logging in to a network" doesn't fit well with
-clients possibly running on multiuser machines (such as users of smbclient
-under Unix). Having said that, several developers are working hard on
-building it in to the next major version of Samba. If you can contribute,
-send a message to samba-bugs!
-
-Seeing this message should not affect your ability to mount redirected disks
-and printers, which is really what all this is about.
-
-For many clients (including Windows for Workgroups and Lan Manager), setting
-the domain to STANDALONE at least gets rid of the message.
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 7: Printing doesn't work :-(
-
-Make sure that the specified print command for the service you are connecting
-to is correct and that it has a fully-qualified path (eg., use "/usr/bin/lpr"
-rather than just "lpr").
-
-Make sure that the spool directory specified for the service is writable by the
-user connected to the service. In particular the user "nobody" often has
-problems with printing, even if it worked with an earlier version of Samba. Try
-creating another guest user other than "nobody".
-
-Make sure that the user specified in the service is permitted to use the
-printer.
-
-Check the debug log produced by smbd. Search for the printer name and see if
-the log turns up any clues. Note that error messages to do with a service ipc$
-are meaningless - they relate to the way the client attempts to retrieve status
-information when using the LANMAN1 protocol.
-
-If using WfWg then you need to set the default protocol to TCP/IP, not Netbeui.
-This is a WfWg bug.
-
-If using the Lanman1 protocol (the default) then try switching to coreplus.
-Also not that print status error messages don't mean printing won't work. The
-print status is received by a different mechanism.
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 8: My programs install on the server OK, but refuse to work properly.
-
-There are numerous possible reasons for this, but one MAJOR possibility is that
-your software uses locking. Make sure you are using Samba 1.6.11 or later. It
-may also be possible to work around the problem by setting "locking=no" in the
-Samba configuration file for the service the software is installed on. This
-should be regarded as a strictly temporary solution.
-
-In earlier Samba versions there were some difficulties with the very latest
-Microsoft products, particularly Excel 5 and Word for Windows 6. These should
-have all been solved. If not then please let Andrew Tridgell know.
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 9: My "server string" doesn't seem to be recognized, my client reports the
- default setting, eg. "Samba 1.9.15p4", instead of what I have changed it
- to in the smb.conf file.
-
-You need to use the -C option in nmbd. The "server string" affects
-what smbd puts out and -C affects what nmbd puts out. In a future
-version these will probably be combined and -C will be removed, but
-for now use -C
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 10: When I attempt to get a listing of available resources from the Samba
- server, my client reports
- "This server is not configured to list shared resources".
-
-Your guest account is probably invalid for some reason. Samba uses
-the guest account for browsing in smbd. Check that your guest account is
-valid.
-
-See also 'guest account' in smb.conf man page.
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 11: You get the message "you appear to have a trapdoor uid system"
- in your logs
-
-This can have several causes. It might be because you are using a uid
-or gid of 65535 or -1. This is a VERY bad idea, and is a big security
-hole. Check carefully in your /etc/passwd file and make sure that no
-user has uid 65535 or -1. Especially check the "nobody" user, as many
-broken systems are shipped with nobody setup with a uid of 65535.
-
-It might also mean that your OS has a trapdoor uid/gid system :-)
-
-This means that once a process changes effective uid from root to
-another user it can't go back to root. Unfortunately Samba relies on
-being able to change effective uid from root to non-root and back
-again to implement its security policy. If your OS has a trapdoor uid
-system this won't work, and several things in Samba may break. Less
-things will break if you use user or server level security instead of
-the default share level security, but you may still strike
-problems.
-
-The problems don't give rise to any security holes, so don't panic,
-but it does mean some of Samba's capabilities will be unavailable.
-In particular you will not be able to connect to the Samba server as
-two different uids at once. This may happen if you try to print as a
-"guest" while accessing a share as a normal user. It may also affect
-your ability to list the available shares as this is normally done as
-the guest user.
-
-Complain to your OS vendor and ask them to fix their system.
-
-Note: the reason why 65535 is a VERY bad choice of uid and gid is that
-it casts to -1 as a uid, and the setreuid() system call ignores (with
-no error) uid changes to -1. This means any daemon attempting to run
-as uid 65535 will actually run as root. This is not good!
-
-===============================================================================
-SECTION FOUR: Specific client problems
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 1: Are any MacIntosh clients for Samba.
-
-Yes. Thursby Software Systems have released 'Dave' - a SMB client for
-MacIntosh systems. This is a commercial product and inclusion in this
-faq does not imply any endorsement by the Samba developers. Having said
-that, the first public demonstration of 'Dave' was to the Samba server
-run by Andrew Tridgell over the Internet from Redmond, Washington, USA to
-Australia as part of the first CIFS developers conference.
-
-For more details on 'Dave' contact :
-
-Web contact: www.thursby.com
-
-Thursby Software Systems, Inc.
-5840 W. Interstate 20
-Arlington, Texas 76017 U.S.A.
-Voice: 817-478-5070
-FAX: 817-561-2313
-sales@thursby.com
-
-There are currently no Free Software solutions other than to make
-your UNIX server talk AppleTalk.
-
-In Rob Newberry's words (rob@eats.com, Sun, 4 Dec 1994):
-
-In future Apple System Software, you may see support for other protocols, such
-as SMB -- Applet is working on a new networking architecture that will make it
-easier to support additional protocols. But it's not here yet.
-
-If you want your Unix machine to speak Appletalk, there are several options.
-"Netatalk" and "CAP" are free, and available on the net. There are also
-several commercial options, such as "PacerShare" and "Helios" (I think).
-In any case, you'll have to look around for a server, not anything for the Mac.
-
-Depending on your OS, some of these may not help you. I am currently
-coordinating the effort to get CAP working with Native Ethertalk under Linux,
-but we're not done yet.
-
-Rob
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 2: I am getting a "Session request failed (131,130)" error when I try to
- connect to my Win95 PC with smbclient. I am able to connect from the PC
- to the Samba server without problems. What gives?
-
-The following answer is provided by John E. Miller:
-
-I'll assume that you're able to ping back and forth between the machines by
-IP address and name, and that you're using some security model where you're
-confident that you've got user IDs and passwords right. The logging options
-(-d3 or greater) can help a lot with that. DNS and WINS configuration can
-also impact connectivity as well.
-
-Now, on to 'scope id's. Somewhere in your Win95 TCP/IP network configuration
-(I'm too much of an NT bigot to know where it's located in the Win95 setup,
-but I'll have to learn someday since I teach for a Microsoft Solution Provider
-Authorized Tech Education Center - what an acronym...) [Note: It's under
-Control Panel | Network | TCP/IP | WINS Configuration] there's a little text
-entry field called something like 'Scope ID'.
-
-This field essentially creates 'invisible' sub-workgroups on the same wire.
-Boxes can only see other boxes whose Scope IDs are set to the exact same
-value - it's sometimes used by OEMs to configure their boxes to browse only
-other boxes from the same vendor and, in most environments, this field should
-be left blank. If you, in fact, have something in this box that EXACT value
-(case-sensitive!) needs to be provided to smbclient and nmbd as the -i
-(lowercase) parameter. So, if your Scope ID is configured as the string
-'SomeStr' in Win95 then you'd have to use smbclient -iSomeStr
-in connecting to it.
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 3: How do I synchronize my PC's clock with my Samba server?
-
-To syncronize your PC's clock with your Samba server:
-
-* Copy timesync.pif to your windows directory
- * timesync.pif can be found at:
- http://samba.canberra.edu.au/pub/samba/binaries/miscellaneous/timesync.pif
-* Add timesync.pif to your 'Start Up' group/folder
-* Open the properties dialog box for the program/icon
- * Make sure the 'Run Minimized' option is set in program 'Properties'
- * Change the command line section that reads \\sambahost to reflect the name
- of your server.
-* Close the properties dialog box by choosing 'OK'
-
-Each time you start your computer (or login for Win95) your PC will
-synchronize its clock with your Samba server.
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 4: Problems with WinDD, NTrigue, WinCenterPro etc
-
-All of the above programs are applications that sit on an NT box and
-allow multiple users to access the NT GUI applications from remote
-workstations (often over X).
-
-What has this got to do with Samba? The problem comes when these users
-use filemanager to mount shares from a Samba server. The most common
-symptom is that the first user to connect get correct file permissions
-and has a nice day, but subsequent connections get logged in as the
-same user as the first person to login. They find that they cannot
-access files in their own home directory, but that they can access
-files in the first users home directory (maybe not such a nice day
-after all?)
-
-Why does this happen? The above products all share a common heritage
-(and code base I believe). They all open just a single TCP based SMB
-connection to the Samba server, and requests from all users are piped
-over this connection. This is unfortunate, but not fatal.
-
-It means that if you run your Samba server in share level security
-(the default) then things will definately break as described above. The
-share level SMB security model has no provision for multiple user IDs
-on the one SMB connection. See security_level.txt in the docs for more
-info on share/user/server level security.
-
-If you run in user or server level security then you have a chance,
-but only if you have a recent version of Samba (at least 1.9.15p6). In
-older versions bugs in Samba meant you still would have had problems.
-
-If you have a trapdoor uid system in your OS then it will never work
-properly. Samba needs to be able to switch uids on the connection and
-it can't if your OS has a trapdoor uid system. You'll know this
-because Samba will note it in your logs.
-
-Also note that you should not use the magic "homes" share name with
-products like these, as otherwise all users will end up with the same
-home directory. Use \\server\username instead.
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 5: Problem with printers under NT
-
-This info from Stefan Hergeth may be useful:
-
- A network-printer (with ethernetcard) is connected to the NT-Clients via
- our UNIX-Fileserver (SAMBA-Server), like the configuration told by
- Matthew Harrell (see WinNT.txt)
-
- 1.) If a user has choosen this printer as the default printer in his
- NT-Session and this printer is not connected to the network
- (e.g. switched off) than this user has a problem with the SAMBA-
- connection of his filesystems. It's very slow.
-
- 2.) If the printer is connected to the network everything works fine.
-
- 3.) When the smbd ist started with debug level 3, you can see that the
- NT spooling system try to connect to the printer many times. If the
- printer ist not connected to the network this request fails and the
- NT spooler is wasting a lot of time to connect to the printer service.
- This seems to be the reason for the slow network connection.
-
- 4.) Maybe it's possible to change this behaviour by setting different printer
- properties in the Print-Manager-Menu of NT, but i didn't try it
- yet.
-
- I hope this information will help in some way.
-
- Stefan Hergeth
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 6: Why are my file's timestamps off by an hour, or by a few hours?
-
-This is from Paul Eggert .
-
-Most likely it's a problem with your time zone settings.
-
-Internally, Samba maintains time in traditional Unix format,
-namely, the number of seconds since 1970-01-01 00:00:00 Universal Time
-(or ``GMT''), not counting leap seconds.
-
-On the server side, Samba uses the Unix TZ variable to convert internal
-timestamps to and from local time. So on the server side, there are two
-things to get right.
-
- 1. The Unix system clock must have the correct Universal time.
- Use the shell command "sh -c 'TZ=UTC0 date'" to check this.
-
- 2. The TZ environment variable must be set on the server
- before Samba is invoked. The details of this depend on the
- server OS, but typically you must edit a file whose name is
- /etc/TIMEZONE or /etc/default/init, or run the command `zic -l'.
-
- 3. TZ must have the correct value.
-
- 3a. If possible, use geographical time zone settings
- (e.g. TZ='America/Los_Angeles' or perhaps
- TZ=':US/Pacific'). These are supported by most
- popular Unix OSes, are easier to get right, and are
- more accurate for historical timestamps. If your
- operating system has out-of-date tables, you should be
- able to update them from the public domain time zone
- tables at .
-
- 3b. If your system does not support geographical time zone
- settings, you must use a Posix-style TZ strings, e.g.
- TZ='PST8PDT,M4.1.0/2,M10.5.0/2' for US Pacific time.
- Posix TZ strings can take the following form (with optional
- items in brackets):
-
- StdOffset[Dst[Offset],Date/Time,Date/Time]
-
- where:
-
- `Std' is the standard time designation (e.g. `PST').
-
- `Offset' is the number of hours behind UTC (e.g. `8').
- Prepend a `-' if you are ahead of UTC, and
- append `:30' if you are at a half-hour offset.
- Omit all the remaining items if you do not use
- daylight-saving time.
-
- `Dst' is the daylight-saving time designation
- (e.g. `PDT').
-
- The optional second `Offset' is the number of
- hours that daylight-saving time is behind UTC.
- The default is 1 hour ahead of standard time.
-
- `Date/Time,Date/Time' specify when daylight-saving
- time starts and ends. The format for a date is
- `Mm.n.d', which specifies the dth day (0 is Sunday)
- of the nth week of the mth month, where week 5 means
- the last such day in the month. The format for a
- time is [h]h[:mm[:ss]], using a 24-hour clock.
-
- Other Posix string formats are allowed but you don't want
- to know about them.
-
-On the client side, you must make sure that your client's clock and
-time zone is also set appropriately. [[I don't know how to do this.]]
-
-Samba traditionally has had many problems dealing with time zones, due
-to the bizarre ways that Microsoft network protocols handle time
-zones. A common symptom is for file timestamps to be off by an hour.
-To work around the problem, try disconnecting from your Samba server
-and then reconnecting to it; or upgrade your Samba server to
-1.9.16alpha10 or later.
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 7: How do I set the printer driver name correctly?
-
-Question:
-> On NT, I opened "Printer Manager" and "Connect to Printer".
-> Enter "\\ptdi270\ps1" in the box of printer. I got the
-> following error message:
->
-> You do not have sufficient access to your machine
-> to connect to the selected printer, since a driver
-> needs to be installed locally.
-
-Answer:
-
-In the more recent versions of Samba you can now set the "printer
-driver" in smb.conf. This tells the client what driver to use. For
-example, I have:
-
- printer driver = HP LaserJet 4L
-
-and NT knows to use the right driver. You have to get this string
-exactly right.
-
-To find the exact string to use, you need to get to the dialog box in
-your client where you select which printer driver to install. The
-correct strings for all the different printers are shown in a listbox
-in that dialog box.
-
-You could also try setting the driver to NULL like this:
-
- printer driver = NULL
-
-this is effectively what older versions of Samba did, so if that
-worked for you then give it a go. If this does work then let me know
-and I'll make it the default. Currently the default is a 0 length
-string.
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-* 8: I have upgraded my NT 4.0 system to service pack 3. Why
- can't I connect anymore ?
-
-This is not a bug. Microsoft has changed their policy on sending
-unencrypted passwords over the net. They no longer default to allowing
-unencrypted passwords to be sent over the net. This effects all Samba
-servers which are configured to use security=share or security=user level
-security without password encryption. They do, however, have a fix which
-can be applied to the registry to fix the problem. Here's a synopsis
-from the SP3 web page that discusses how to enable unencrypted password
-sending from an NT 4.0 box.
-
-A better solution is to re-compile Samba to use encrypted passwords.
-See the document :
-
-ftp://samba.anu.edu.au/pub/samba/docs/ENCRYPTION.txt
-
->SYMPTOMS
->==========
->
->Connecting to SMB servers (such as Samba) with unencrypted password fails
-after upgrading to Windows NT 4.0 service pack 3 version 1.76.
->
->CAUSE
->======
->
->The SMB redirector in Windows NT 4.0 service pack 3 version 1.76 handles
->unencrypted passwords differently than previous version of Windows NT.
->Beginning with this version, the SMB redirector will not send an
->unencrypted password unless you add a registry entry to enable them.
->
->RESOLUTION
->===========
->
->To enable unencrypted (plain text) passwords modify the registry in this way.
->
->
->
->WARNING: Using Registry Editor incorrectly can cause serious, system-wide
->problems that may require you to reinstall Windows NT to correct them.
->Microsoft cannot guarantee that any problems resulting from the use of
->Registry Editor can be solved. Use this tool at your own risk.
->
->
->
->1. Run Registry Editor (REGEDT32.EXE).
->
->2. From the HKEY_LOCAL_MACHINE subtree, go to the following key:
->
->
->
->\system\currentcontrolset\services\rdr\parameters
->
->
->
->3. From the Edit menu, select Add Value.
->
->4. Add the following:
->
->
->
->Value Name: EnablePlainTextPassword
->
->Data Type: REG_DWORD
->
->Data: 1
->
->
->
->5. Choose OK and quit Registry Editor.
->
->6. Shutdown and restart Windows NT.
->
->
------------------------------------------------------------------------
-
-===============================================================================
-SECTION FIVE: Specific client application problems
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* 1: MS Office Setup reports "Cannot change properties of the file named:
- X:\MSOFFICE\SETUP.INI"
-
-When installing MS Office on a Samba drive for which you have admin user
-permissions, ie. admin users = , you will find the setup program
-unable to complete the installation.
-
-To get around this problem, do the installation without admin user permissions
-The problem is that MS Office Setup checks that a file is rdonly by trying to
-open it for writing.
-
-Admin users can always open a file for writing, as they run as root.
-You just have to install as a non-admin user and then use "chown -R" to fix
-the owner.
-
-===============================================================================
-SECTION SIX: Miscellaneous
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Maintained By Paul Blackman, Email:ictinus@lake.canberra.edu.au
diff --git a/docs/textdocs/BUGS.txt b/docs/textdocs/BUGS.txt
index 0bd12e8af0a..5fc069371b3 100644
--- a/docs/textdocs/BUGS.txt
+++ b/docs/textdocs/BUGS.txt
@@ -25,7 +25,7 @@ that list that may be able to help you.
You may also like to look though the recent mailing list archives,
which are conveniently accessible on the Samba web pages
-at http://samba.canberra.edu.au/pub/samba/
+at http://samba.anu.edu.au/samba/
GENERAL INFO
diff --git a/docs/textdocs/MIRRORS.txt b/docs/textdocs/MIRRORS.txt
index 01bc277a20b..c9bd04f1c83 100755
--- a/docs/textdocs/MIRRORS.txt
+++ b/docs/textdocs/MIRRORS.txt
@@ -1,6 +1,9 @@
The main Samba ftp site is samba.anu.edu.au in pub/samba/. Contact
samba-bugs@samba.anu.edu.au for help with this site.
+The 'Source Only' sites may also contain binary packages as we are now
+including them on samba.anu.edu.au/pub/samba/Binary_Packages
+
Mirror sites include:
Source Only
@@ -18,6 +21,8 @@ Source Only
--- Germany ---
ftp://ftp.uni-trier.de/pub/unix/network/samba/
ftp://ftp.gwdg.de/pub/server/samba/
+--- Greece ---
+ ftp://ftp.ntua.gr/pub/net/samba/
--- Japan ---
ftp://ring.asahi-net.or.jp/archives/net/samba/
ftp://ring.aist.go.jp/archives/net/samba/
@@ -28,8 +33,12 @@ Source Only
ftp://ftp.gbnet.net/pub/samba/
ftp://ftp.ntrl.net/pub/mirror/samba/
ftp://despair.capecod.net/pub/Samba/
+--- Poland ---
+ ftp://giswitch.sggw.waw.pl/pub/unix/samba/
--- Portugal ---
ftp://ftp.ua.pt/pub/misc/samba/
+--- Romania ---
+ ftp.romus.ro/pub/Linux/Network/samba/
--- Russian Federation ---
ftp://ftp.uic.nsu.ru/pub/vendors/samba/
--- United Kingdom ---
@@ -75,7 +84,7 @@ There are several others. Give archie a try.
Http sites include:
===================
-http://samba.canberra.edu.au/pub/samba
+http://samba.anu.edu.au/samba
http://www.choc.satech.net.au/pub/samba/
diff --git a/docs/textdocs/UNIX_INSTALL.txt b/docs/textdocs/UNIX_INSTALL.txt
index c189482ca41..d78c36a4c9c 100644
--- a/docs/textdocs/UNIX_INSTALL.txt
+++ b/docs/textdocs/UNIX_INSTALL.txt
@@ -15,7 +15,7 @@ try something like:
Unfortunately, having said this, the man pages are sadly out of date and
really need more effort to maintain them. Other sources of information
-are pointed to by the Samba web site, http://samba.canberra.edu.au/pub/samba.
+are pointed to by the Samba web site, http://samba.anu.edu.au/samba.
STEP 1. Building the binaries
--
cgit
From 9a81cb171c178a85ecd045afafbce7d4b481344e Mon Sep 17 00:00:00 2001
From: Samba Release Account
Date: Tue, 7 Oct 1997 04:50:53 +0000
Subject: Oops forgot to run the sgml converters that one last time. All done.
Paul.
---
docs/faq/Samba-Server-FAQ.html | 2 +-
docs/faq/Samba-meta-FAQ.html | 2 +-
docs/faq/Samba-meta-FAQ.txt | 4 ++--
docs/faq/sambafaq.html | 2 +-
docs/faq/sambafaq.txt | 4 ++--
5 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/docs/faq/Samba-Server-FAQ.html b/docs/faq/Samba-Server-FAQ.html
index 501ff1b1ed8..eadc3e26ede 100644
--- a/docs/faq/Samba-Server-FAQ.html
+++ b/docs/faq/Samba-Server-FAQ.html
@@ -39,7 +39,7 @@ Table of Contents
Samba Server FAQ
-Dan Shearer & Paul Blackman, ictinus@lake.canberra.edu.au
v 0.1, 23 Aug '97
+Dan Shearer & Paul Blackman, ictinus@samba.anu.edu.au
v 0.3, 7 Oct '97
This is the Server Frequently Asked Questions (FAQ)
document for Samba, the free and very popular SMB and CIFS server
product. A general
diff --git a/docs/faq/Samba-meta-FAQ.html b/docs/faq/Samba-meta-FAQ.html
index 7821083740d..5a70808867b 100644
--- a/docs/faq/Samba-meta-FAQ.html
+++ b/docs/faq/Samba-meta-FAQ.html
@@ -37,7 +37,7 @@ Table of Contents
Samba meta FAQ
-Dan Shearer & Paul Blackman, ictinus@lake.canberra.edu.au
v 0.1, 23 Aug '97
+Dan Shearer & Paul Blackman, ictinus@samba.anu.edu.au
v 0.3, 7 Oct '97
This is the meta-Frequently Asked Questions (FAQ) document
for Samba, the free and very popular SMB and CIFS server product. It
contains overview information for the Samba suite of programs, a
diff --git a/docs/faq/Samba-meta-FAQ.txt b/docs/faq/Samba-meta-FAQ.txt
index 4fb1ed65442..65d9a57ff62 100644
--- a/docs/faq/Samba-meta-FAQ.txt
+++ b/docs/faq/Samba-meta-FAQ.txt
@@ -1,6 +1,6 @@
Samba meta FAQ
- Dan Shearer & Paul Blackman, ictinus@lake.canberra.edu.au
- v 0.1, 23 Aug '97
+ Dan Shearer & Paul Blackman, ictinus@samba.anu.edu.au
+ v 0.3, 7 Oct '97
This is the meta-Frequently Asked Questions (FAQ) document for Samba,
the free and very popular SMB and CIFS server product. It contains
diff --git a/docs/faq/sambafaq.html b/docs/faq/sambafaq.html
index 9e3d21ad137..9c45d524dd3 100644
--- a/docs/faq/sambafaq.html
+++ b/docs/faq/sambafaq.html
@@ -45,7 +45,7 @@ Table of Contents
Samba FAQ
-Paul Blackman, ictinus@lake.canberra.edu.au
v 0.7, June '97
+Paul Blackman, ictinus@samba.anu.edu.au
v 0.8, June '97
This is the Frequently Asked Questions (FAQ) document for
Samba, the free and very popular SMB server product. An SMB server
allows file and printer connections from clients such as Windows,
diff --git a/docs/faq/sambafaq.txt b/docs/faq/sambafaq.txt
index 49cfa479fe9..7108846ae67 100644
--- a/docs/faq/sambafaq.txt
+++ b/docs/faq/sambafaq.txt
@@ -1,6 +1,6 @@
Samba FAQ
- Paul Blackman, ictinus@lake.canberra.edu.au
- v 0.7, June '97
+ Paul Blackman, ictinus@samba.anu.edu.au
+ v 0.8, June '97
This is the Frequently Asked Questions (FAQ) document for Samba, the
free and very popular SMB server product. An SMB server allows file
--
cgit
From 5a38eaac75a6bede2d946f69cf664d7ca3989b55 Mon Sep 17 00:00:00 2001
From: Samba Release Account
Date: Tue, 7 Oct 1997 04:56:02 +0000
Subject: More references to samba.canberra Mental note: always commit from
root directory. :^o Paul.
---
README | 6 +++---
examples/misc/extra_smbstatus | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/README b/README
index ba982448e14..30103241841 100644
--- a/README
+++ b/README
@@ -45,7 +45,7 @@ printers) from unix, Netware and other operating systems
- a tar extension to the client for backing up PCs
For a much better overview have a look at the web site at
-http://samba.canberra.edu.au/pub/samba, and browse the user survey.
+http://samba.anu.edu.au/samba, and browse the user survey.
Related packages include:
@@ -141,12 +141,12 @@ WEB SITE
A Samba WWW site has been setup with lots of useful info. Connect to:
-http://samba.canberra.edu.au/pub/samba/
+http://samba.anu.edu.au/samba/
As well as general information and documentation, this also has searchable
archives of the mailing list and a user survey that shows who else is using
this package. Have you registered with the survey yet? :-)
It is maintained by Paul Blackman (thanks Paul!). You can contact him
-at ictinus@lake.canberra.edu.au.
+at ictinus@samba.anu.edu.au.
diff --git a/examples/misc/extra_smbstatus b/examples/misc/extra_smbstatus
index 363e7f67af5..584284feb34 100644
--- a/examples/misc/extra_smbstatus
+++ b/examples/misc/extra_smbstatus
@@ -46,5 +46,5 @@ Cheers,
| | "Spend a little love and get high"
_/ \_ | - Lenny Kravitz
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-~~~~ SAMBA Web Pages: http://samba.canberra.edu.au/pub/samba/samba.html ~~~~~
+~~~~~~~~~~~~~~ SAMBA Web Pages: http://samba.anu.edu.au/samba/ ~~~~~~~~~~~~~~
--
cgit
From bf1f8b1567cb46e3e73ae8dbb26f6228cf519c1f Mon Sep 17 00:00:00 2001
From: Andrew Tridgell
Date: Tue, 7 Oct 1997 11:14:27 +0000
Subject: get rid of SIGCLD_IGNORE for HPUX. A user reported it causing lots of
defunct smbd processes.
Andrew
---
source/include/includes.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/source/include/includes.h b/source/include/includes.h
index 2329553d234..d1afc34de92 100644
--- a/source/include/includes.h
+++ b/source/include/includes.h
@@ -563,7 +563,9 @@ char *mktemp(char *); /* No standard include */
#define USE_SETSID
#define USE_SETRES
#define DEFAULT_PRINTING PRINT_HPUX
-#define SIGCLD_IGNORE
+/* Ken Weiss tells us that SIGCLD_IGNORE is
+ not good for HPUX */
+/* #define SIGCLD_IGNORE */
#endif /* HPUX */
--
cgit
From bef10e388ac8661afc465a64524ba55f8c5bea0c Mon Sep 17 00:00:00 2001
From: Andrew Tridgell
Date: Tue, 7 Oct 1997 11:18:26 +0000
Subject: get rid of SIGCLD_IGNORE for HPUX. A user reported it causing lots of
defunct smbd processes.
Andrew
---
source/include/includes.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/source/include/includes.h b/source/include/includes.h
index e66ceb2d70c..4e48e87a7c1 100644
--- a/source/include/includes.h
+++ b/source/include/includes.h
@@ -563,7 +563,9 @@ char *mktemp(char *); /* No standard include */
#define USE_SETSID
#define USE_SETRES
#define DEFAULT_PRINTING PRINT_HPUX
-#define SIGCLD_IGNORE
+/* Ken Weiss tells us that SIGCLD_IGNORE is
+ not good for HPUX */
+/* #define SIGCLD_IGNORE */
#endif /* HPUX */
--
cgit
From b12b3626fd9ccc9cdf2111937b3ee344da361b1f Mon Sep 17 00:00:00 2001
From: Andrew Tridgell
Date: Tue, 7 Oct 1997 14:36:22 +0000
Subject: increase the debug level in the "added interface" debug line
---
source/lib/interface.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/source/lib/interface.c b/source/lib/interface.c
index 940af1eccf4..147425d0fc1 100644
--- a/source/lib/interface.c
+++ b/source/lib/interface.c
@@ -337,9 +337,9 @@ static void interpret_interfaces(char *s, struct interface **interfaces,
iface->next = NULL;
(*interfaces) = last_iface = iface;
- DEBUG(1,("Added interface ip=%s ",inet_ntoa(iface->ip)));
- DEBUG(1,("bcast=%s ",inet_ntoa(iface->bcast)));
- DEBUG(1,("nmask=%s\n",inet_ntoa(iface->nmask)));
+ DEBUG(2,("Added interface ip=%s ",inet_ntoa(iface->ip)));
+ DEBUG(2,("bcast=%s ",inet_ntoa(iface->bcast)));
+ DEBUG(2,("nmask=%s\n",inet_ntoa(iface->nmask)));
}
--
cgit
From d98f9bbbdef02e46428c6eb954ebc5513bbc5c1c Mon Sep 17 00:00:00 2001
From: Andrew Tridgell
Date: Tue, 7 Oct 1997 14:36:51 +0000
Subject: increase the debug level in the "added interface" debug line
---
source/lib/interface.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/source/lib/interface.c b/source/lib/interface.c
index 940af1eccf4..147425d0fc1 100644
--- a/source/lib/interface.c
+++ b/source/lib/interface.c
@@ -337,9 +337,9 @@ static void interpret_interfaces(char *s, struct interface **interfaces,
iface->next = NULL;
(*interfaces) = last_iface = iface;
- DEBUG(1,("Added interface ip=%s ",inet_ntoa(iface->ip)));
- DEBUG(1,("bcast=%s ",inet_ntoa(iface->bcast)));
- DEBUG(1,("nmask=%s\n",inet_ntoa(iface->nmask)));
+ DEBUG(2,("Added interface ip=%s ",inet_ntoa(iface->ip)));
+ DEBUG(2,("bcast=%s ",inet_ntoa(iface->bcast)));
+ DEBUG(2,("nmask=%s\n",inet_ntoa(iface->nmask)));
}
--
cgit
From 3e16fc01ed748129c1587acc6330730f3cfbf77a Mon Sep 17 00:00:00 2001
From: Andrew Tridgell
Date: Tue, 7 Oct 1997 14:38:31 +0000
Subject: increase the debug level in the "client requested max ..." debug line
---
source/smbd/reply.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source/smbd/reply.c b/source/smbd/reply.c
index f3a8ad22b8a..31915e6acac 100644
--- a/source/smbd/reply.c
+++ b/source/smbd/reply.c
@@ -598,7 +598,7 @@ int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize)
if (!done_sesssetup)
max_send = MIN(max_send,smb_bufsize);
- DEBUG(1,(" Client requested max send size of %d\n", max_send));
+ DEBUG(5,(" Client requested max send size of %d\n", max_send));
done_sesssetup = True;
--
cgit
From b37e21273e81b875876e8e8ddf6804714044ffd8 Mon Sep 17 00:00:00 2001
From: Luke Leighton
Date: Tue, 7 Oct 1997 14:58:07 +0000
Subject: pipes.c:
some routines to create LSA RPC packets. none of them are used.
lsaparse.c:
smbparse.c:
smb.h:
more tidy-up.
---
source/include/proto.h | 1 +
source/include/smb.h | 47 ++++++----
source/lsaparse.c | 14 +++
source/smbd/pipes.c | 238 ++++++++++++++++++++++++++++++++++++++++++++++++-
source/smbparse.c | 3 +-
5 files changed, 285 insertions(+), 18 deletions(-)
diff --git a/source/include/proto.h b/source/include/proto.h
index 202b1511504..8f8ec5aa8a1 100644
--- a/source/include/proto.h
+++ b/source/include/proto.h
@@ -312,6 +312,7 @@ BOOL remove_share_oplock(int fnum, share_lock_token token);
/*The following definitions come from lsaparse.c */
+char* lsa_io_r_open_pol(BOOL io, LSA_R_OPEN_POL *r_p, char *q, char *base, int align);
char* lsa_io_q_query(BOOL io, LSA_Q_QUERY_INFO *q_q, char *q, char *base, int align);
char* lsa_io_r_query(BOOL io, LSA_R_QUERY_INFO *r_q, char *q, char *base, int align);
char* lsa_io_q_lookup_sids(BOOL io, LSA_Q_LOOKUP_SIDS *q_s, char *q, char *base, int align);
diff --git a/source/include/smb.h b/source/include/smb.h
index 43e402359f0..4850b33e494 100644
--- a/source/include/smb.h
+++ b/source/include/smb.h
@@ -331,16 +331,6 @@ typedef struct domsid2_info
} DOM_SID2;
-/* DOM_SID3 - domain SID structure - SIDs stored in unicode */
-typedef struct domsid3_info
-{
- UNISTR str; /* domain SID unicode string */
- uint32 undoc; /* value is 0 */
- uint32 type1; /* value is 1 */
- uint32 type2; /* value is 5 or 3 */
-
-} DOM_SID3;
-
/* DOM_RID2 - domain RID structure */
typedef struct domrid2_info
{
@@ -409,8 +399,8 @@ typedef struct id_info_1
DOM_LOGON_ID logon_id; /* logon ID */
UNIHDR hdr_user_name; /* user name unicode header */
UNIHDR hdr_workgroup_name; /* workgroup name unicode header */
- ARC4_OWF arc4_lm_owf; /* arc4 LM OWF Password */
- ARC4_OWF arc4_nt_owf; /* arc4 NT OWF Password */
+ ARC4_OWF arc4_lm_owf; /* rc4 LM OWF Password */
+ ARC4_OWF arc4_nt_owf; /* rc4 NT OWF Password */
UNISTR2 uni_domain_name; /* domain name unicode string */
UNISTR2 uni_user_name; /* user name unicode string */
UNISTR2 uni_workgroup_name; /* workgroup name unicode string */
@@ -463,10 +453,11 @@ typedef struct rpc_hdr_info
typedef struct dom_query_info
{
uint16 uni_dom_max_len; /* domain name string length * 2 */
+ uint16 padding; /* 2 padding bytes? */
uint16 uni_dom_str_len; /* domain name string length * 2 */
uint32 buffer_dom_name; /* undocumented domain name string buffer pointer */
uint32 buffer_dom_sid; /* undocumented domain SID string buffer pointer */
- UNISTR uni_domain_name; /* domain name (unicode string) */
+ UNISTR2 uni_domain_name; /* domain name (unicode string) */
DOM_SID dom_sid; /* domain SID */
} DOM_QUERY;
@@ -475,14 +466,25 @@ typedef struct dom_query_info
typedef DOM_QUERY DOM_QUERY_3;
typedef DOM_QUERY DOM_QUERY_5;
+#define POL_HND_SIZE 20
+
/* LSA_POL_HND */
typedef struct lsa_policy_info
{
- uint8 data[20]; /* policy handle */
+ uint8 data[POL_HND_SIZE]; /* policy handle */
} LSA_POL_HND;
+/* LSA_R_OPEN_POL - response to LSA Open Policy */
+typedef struct lsa_r_open_pol_info
+{
+ LSA_POL_HND pol; /* policy handle */
+
+ uint32 status; /* return code */
+
+} LSA_R_OPEN_POL;
+
/* LSA_Q_QUERY_INFO - LSA query info policy */
typedef struct lsa_query_info
{
@@ -530,7 +532,6 @@ typedef struct dom_ref_info
/* LSA_Q_LOOKUP_SIDS - LSA Lookup SIDs */
typedef struct lsa_q_lookup_sids
{
-
LSA_POL_HND pol_hnd; /* policy handle */
uint32 num_entries;
uint32 buffer_dom_sid; /* undocumented domain SID buffer pointer */
@@ -669,7 +670,7 @@ typedef struct lsa_q_srv_pwset_info
/* LSA_R_SRV_PWSET */
typedef struct lsa_r_srv_pwset_info
{
- DOM_CHAL srv_chal; /* server-calculated credentials */
+ DOM_CRED srv_cred; /* server-calculated credentials */
uint32 status; /* return code */
@@ -1040,8 +1041,10 @@ typedef struct
{
smb_shm_offset_t next_share_mode_entry;
int pid;
+#ifdef USE_OPLOCKS
uint16 op_port;
uint16 op_type;
+#endif /* USE_OPLOCKS */
int share_mode;
struct timeval time;
} share_mode_entry;
@@ -1050,8 +1053,10 @@ typedef struct
typedef struct
{
int pid;
+#ifdef USE_OPLOCKS
uint16 op_port;
uint16 op_type;
+#endif /* USE_OPLOCKS */
int share_mode;
struct timeval time;
} min_share_mode_entry;
@@ -1077,7 +1082,11 @@ struct connect_record
};
#ifndef LOCKING_VERSION
+#ifdef USE_OPLOCKS
#define LOCKING_VERSION 4
+#else /* USE_OPLOCKS */
+#define LOCKING_VERSION 3
+#endif /* USE_OPLOCKS */
#endif /* LOCKING_VERSION */
#if !defined(FAST_SHARE_MODES)
@@ -1093,7 +1102,11 @@ struct connect_record
#define SMF_FILENAME_LEN_OFFSET 8
#define SMF_HEADER_LENGTH 10
+#ifdef USE_OPLOCKS
#define SMF_ENTRY_LENGTH 20
+#else /* USE_OPLOCKS */
+#define SMF_ENTRY_LENGTH 16
+#endif /* USE_OPLOCKS */
/*
* Share mode record offsets.
@@ -1104,8 +1117,10 @@ struct connect_record
#define SME_SHAREMODE_OFFSET 8
#define SME_PID_OFFSET 12
+#ifdef USE_OPLOCKS
#define SME_PORT_OFFSET 16
#define SME_OPLOCK_TYPE_OFFSET 18
+#endif /* USE_OPLOCKS */
#endif /* FAST_SHARE_MODES */
diff --git a/source/lsaparse.c b/source/lsaparse.c
index 70d4f493800..43e7ef1d402 100644
--- a/source/lsaparse.c
+++ b/source/lsaparse.c
@@ -24,6 +24,20 @@
extern int DEBUGLEVEL;
+/*******************************************************************
+reads or writes an LSA_R_OPEN_POL structure.
+********************************************************************/
+char* lsa_io_r_open_pol(BOOL io, LSA_R_OPEN_POL *r_p, char *q, char *base, int align)
+{
+ if (r_p == NULL) return NULL;
+
+ q = smb_io_pol_hnd(io, &(r_p->pol), q, base, align);
+
+ RW_IVAL(io, q, r_p->status, 0); q += 4;
+
+ return q;
+}
+
/*******************************************************************
reads or writes an LSA_Q_QUERY_INFO structure.
********************************************************************/
diff --git a/source/smbd/pipes.c b/source/smbd/pipes.c
index a465e911459..0fb8a89c9e1 100644
--- a/source/smbd/pipes.c
+++ b/source/smbd/pipes.c
@@ -2,7 +2,9 @@
Unix SMB/Netbios implementation.
Version 1.9.
Pipe SMB reply routines
- Copyright (C) Andrew Tridgell 1992-1997
+ Copyright (C) Andrew Tridgell 1992-1997,
+ Paul Ashton 1997,
+ Luke Kenneth Casson Leighton 1996-1997.
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
@@ -51,6 +53,9 @@ a packet to ensure chaining works correctly */
char * known_pipes [] =
{
"lsarpc",
+#if 0
+ "NETLOGON",
+#endif
NULL
};
@@ -357,3 +362,234 @@ BOOL api_LsarpcTNP(int cnum,int uid, char *param,char *data,
}
return(True);
}
+
+/*
+ PAXX: Someone fix above.
+ The above API is indexing RPC calls based on RPC flags and
+ fragment length. I've decided to do it based on operation number :-)
+*/
+
+/* BIG NOTE: this function only does SIDS where the identauth is not >= 2^32 */
+/* identauth >= 2^32 can be detected because it will be specified in hex */
+static void init_dom_sid(DOM_SID *sid, char *domsid)
+{
+ int identauth;
+ char *p;
+
+ DEBUG(4,("netlogon domain SID: %s\n", domsid));
+
+ /* assume, but should check, that domsid starts "S-" */
+ p = strtok(domsid+2,"-");
+ sid->sid_no = atoi(p);
+
+ /* identauth in decimal should be < 2^32 */
+ /* identauth in hex should be >= 2^32 */
+ identauth = atoi(strtok(0,"-"));
+
+ DEBUG(4,("netlogon rev %d\n", sid->sid_no));
+ DEBUG(4,("netlogon %s ia %d\n", p, identauth));
+
+ sid->id_auth[0] = 0;
+ sid->id_auth[1] = 0;
+ sid->id_auth[2] = (identauth & 0xff000000) >> 24;
+ sid->id_auth[3] = (identauth & 0x00ff0000) >> 16;
+ sid->id_auth[4] = (identauth & 0x0000ff00) >> 8;
+ sid->id_auth[5] = (identauth & 0x000000ff);
+
+ sid->num_auths = 0;
+
+ while ((p = strtok(0, "-")) != NULL)
+ {
+ sid->sub_auths[sid->num_auths++] = atoi(p);
+ }
+}
+
+static void create_rpc_reply(RPC_HDR *hdr, uint32 call_id, int data_len)
+{
+ if (hdr == NULL) return;
+
+ hdr->major = 5; /* RPC version 5 */
+ hdr->minor = 0; /* minor version 0 */
+ hdr->pkt_type = 2; /* RPC response packet */
+ hdr->frag = 3; /* first frag + last frag */
+ hdr->pack_type = 1; /* packed data representation */
+ hdr->frag_len = data_len; /* fragment length, fill in later */
+ hdr->auth_len = 0; /* authentication length */
+ hdr->call_id = call_id; /* call identifier - match incoming RPC */
+ hdr->alloc_hint = data_len - 0x18; /* allocation hint (no idea) */
+ hdr->context_id = 0; /* presentation context identifier */
+ hdr->cancel_count = 0; /* cancel count */
+ hdr->reserved = 0; /* reserved */
+}
+
+static void init_rpc_reply(char *inbuf, char *q, char *base, int data_len)
+{
+ uint32 callid = RIVAL(inbuf, 12);
+ RPC_HDR hdr;
+
+ create_rpc_reply(&hdr, callid, data_len);
+ smb_io_rpc_hdr(False, &hdr, q, base, 4);
+}
+
+static int lsa_reply_open_policy(char *q, char *base)
+{
+ char *start = q;
+ LSA_R_OPEN_POL r_o;
+
+ /* set up the LSA QUERY INFO response */
+ bzero(&(r_o.pol.data), POL_HND_SIZE);
+ r_o.status = 0x0;
+
+ /* store the response in the SMB stream */
+ q = lsa_io_r_open_pol(False, &r_o, q, base, 4);
+
+ /* return length of SMB data stored */
+ return q - start;
+}
+
+static void init_unistr2(UNISTR2 *str, char *buf, int len, char terminate)
+{
+ /* set up string lengths. add one if string is not null-terminated */
+ str->uni_max_len = len + (terminate != 0 ? 1 : 0);
+ str->undoc = 0;
+ str->uni_str_len = len;
+
+ /* store the string (null-terminated copy) */
+ PutUniCode((char *)str->buffer, buf);
+
+ /* overwrite the last character: some strings are terminated with 4 not 0 */
+ str->buffer[len] = (uint16)terminate;
+}
+
+static void init_dom_query(DOM_QUERY *d_q, char *dom_name, char *dom_sid)
+{
+ int domlen = strlen(dom_name);
+
+ d_q->uni_dom_max_len = domlen * 2;
+ d_q->padding = 0;
+ d_q->uni_dom_str_len = domlen * 2;
+
+ d_q->buffer_dom_name = 0; /* domain buffer pointer */
+ d_q->buffer_dom_sid = 0; /* domain sid pointer */
+
+ /* NOT null-terminated: 4-terminated instead! */
+ init_unistr2(&(d_q->uni_domain_name), dom_name, domlen, 4);
+
+ init_dom_sid(&(d_q->dom_sid), dom_sid);
+}
+
+static int lsa_reply_query_info(LSA_Q_QUERY_INFO *q_q, char *q, char *base,
+ char *dom_name, char *dom_sid)
+{
+ char *start = q;
+ LSA_R_QUERY_INFO r_q;
+
+ /* set up the LSA QUERY INFO response */
+
+ r_q.undoc_buffer = 1; /* not null */
+ r_q.info_class = q_q->info_class;
+
+ init_dom_query(&r_q.dom.id5, dom_name, dom_sid);
+
+ r_q.status = 0x0;
+
+ /* store the response in the SMB stream */
+ q = lsa_io_r_query(False, &r_q, q, base, 4);
+
+ /* return length of SMB data stored */
+ return q - start;
+}
+
+static void init_lsa_r_req_chal(LSA_R_REQ_CHAL *r_c, char chal[8], int status)
+{
+ memcpy(r_c->srv_chal.data, chal, sizeof(r_c->srv_chal.data));
+ r_c->status = status;
+}
+
+#if 0
+ char chal[8];
+ /* PAXX: set these to random values */
+ for (int i = 0; i < 8; i+++)
+ {
+ chal[i] = 0xA5;
+ }
+#endif
+
+static int lsa_reply_req_chal(LSA_Q_REQ_CHAL *q_c, char *q, char *base,
+ char chal[8])
+{
+ char *start = q;
+ LSA_R_REQ_CHAL r_c;
+
+ /* set up the LSA REQUEST CHALLENGE response */
+
+ init_lsa_r_req_chal(&r_c, chal, 0);
+
+ /* store the response in the SMB stream */
+ q = lsa_io_r_req_chal(False, &r_c, q, base, 4);
+
+ /* return length of SMB data stored */
+ return q - start;
+}
+
+static void init_lsa_chal(DOM_CHAL *cred, char resp_cred[8])
+{
+ memcpy(cred->data, resp_cred, sizeof(cred->data));
+}
+
+static void init_lsa_r_auth_2(LSA_R_AUTH_2 *r_a,
+ char resp_cred[8], NEG_FLAGS *flgs, int status)
+{
+ init_lsa_chal(&(r_a->srv_chal), resp_cred);
+ memcpy(&(r_a->srv_flgs), flgs, sizeof(r_a->srv_flgs));
+ r_a->status = status;
+}
+
+static int lsa_reply_auth_2(LSA_Q_AUTH_2 *q_a, char *q, char *base,
+ char resp_cred[8], int status)
+{
+ char *start = q;
+ LSA_R_AUTH_2 r_a;
+
+ /* set up the LSA AUTH 2 response */
+
+ init_lsa_r_auth_2(&r_a, resp_cred, &(q_a->clnt_flgs), status);
+
+ /* store the response in the SMB stream */
+ q = lsa_io_r_auth_2(False, &r_a, q, base, 4);
+
+ /* return length of SMB data stored */
+ return q - start;
+}
+
+static void init_lsa_dom_chal(DOM_CRED *cred, char srv_chal[8], UTIME srv_time)
+{
+ init_lsa_chal(&(cred->challenge), srv_chal);
+ cred->timestamp = srv_time;
+}
+
+
+static void init_lsa_r_srv_pwset(LSA_R_SRV_PWSET *r_a,
+ char srv_chal[8], UTIME srv_time, int status)
+{
+ init_lsa_dom_chal(&(r_a->srv_cred), srv_chal, srv_time);
+ r_a->status = status;
+}
+
+static int lsa_reply_srv_pwset(LSA_Q_SRV_PWSET *q_s, char *q, char *base,
+ char srv_cred[8], UTIME srv_time,
+ int status)
+{
+ char *start = q;
+ LSA_R_SRV_PWSET r_s;
+
+ /* set up the LSA Server Password Set response */
+ init_lsa_r_srv_pwset(&r_s, srv_cred, srv_time, status);
+
+ /* store the response in the SMB stream */
+ q = lsa_io_r_srv_pwset(False, &r_s, q, base, 4);
+
+ /* return length of SMB data stored */
+ return q - start;
+}
+
diff --git a/source/smbparse.c b/source/smbparse.c
index 95390522ff5..7ea140f7cb7 100644
--- a/source/smbparse.c
+++ b/source/smbparse.c
@@ -416,7 +416,7 @@ char* smb_io_pol_hnd(BOOL io, LSA_POL_HND *pol, char *q, char *base, int align)
q = align_offset(q, base, align);
- RW_PCVAL(io, q, pol->data, 20); q += 20;
+ RW_PCVAL(io, q, pol->data, POL_HND_SIZE); q += POL_HND_SIZE;
return q;
}
@@ -448,6 +448,7 @@ char* smb_io_dom_query(BOOL io, DOM_QUERY *d_q, char *q, char *base, int align)
RW_SVAL(io, q, d_q->uni_dom_max_len, 0); q += 2; /* domain name string length * 2 */
+ RW_SVAL(io, q, d_q->padding , 0); q += 2; /* 2 padding bytes */
RW_SVAL(io, q, d_q->uni_dom_str_len, 0); q += 2; /* domain name string length * 2 */
RW_IVAL(io, q, d_q->buffer_dom_name, 0); q += 4; /* undocumented domain name string buffer pointer */
--
cgit
From 67c1e87e8fda724da6dd3663641639167dd33a16 Mon Sep 17 00:00:00 2001
From: John Terpstra
Date: Tue, 7 Oct 1997 16:01:08 +0000
Subject: JHT ==> Fixing blocksize argument. Patch by: Llyod Whiteman
---
source/script/smbtar | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source/script/smbtar b/source/script/smbtar
index a947476dc6b..dcf01edb208 100644
--- a/source/script/smbtar
+++ b/source/script/smbtar
@@ -88,7 +88,7 @@ while getopts rivl:b:d:N:s:p:x:u:Xt: c; do
server="$OPTARG"
;;
b) # specify [b]locksize
- blocksize="blocksize $OPTARG"
+ blocksize="$OPTARG"
case "$OPTARG" in
[0-9]*) ;;
*) echo >&2 "$0: Error, block size not numeric: -b $OPTARG"
--
cgit
From bef12478d212a950578843d6d4dece1f153bfd25 Mon Sep 17 00:00:00 2001
From: Luke Leighton
Date: Tue, 7 Oct 1997 18:18:10 +0000
Subject: pipes.c:
more static unused functions in pipes.c for the LSA RPC stream.
smb.h:
corrections and altercations over the documentation
lsaparse.c:
reflecting alterations in LSA structures...
---
source/include/smb.h | 9 +--
source/lsaparse.c | 5 +-
source/smbd/pipes.c | 200 ++++++++++++++++++++++++++++++++++++++++++++++-----
3 files changed, 191 insertions(+), 23 deletions(-)
diff --git a/source/include/smb.h b/source/include/smb.h
index 4850b33e494..3adb3e5a4cb 100644
--- a/source/include/smb.h
+++ b/source/include/smb.h
@@ -677,6 +677,7 @@ typedef struct lsa_r_srv_pwset_info
} LSA_R_SRV_PWSET;
#define LSA_MAX_GROUPS 32
+#define LSA_MAX_SIDS 32
/* LSA_USER_INFO */
typedef struct lsa_q_user_info
@@ -714,8 +715,8 @@ typedef struct lsa_q_user_info
uint32 buffer_dom_id; /* undocumented logon domain id pointer */
char padding[40]; /* unused padding bytes? */
- uint32 num_sids; /* 0 - num_sids */
- uint32 buffer_sids; /* NULL - undocumented pointer to SIDs. */
+ uint32 num_other_sids; /* 0 - num_sids */
+ uint32 buffer_other_sids; /* NULL - undocumented pointer to SIDs. */
UNISTR2 uni_user_name; /* username unicode string */
UNISTR2 uni_full_name; /* user's full name unicode string */
@@ -730,8 +731,8 @@ typedef struct lsa_q_user_info
UNISTR2 uni_logon_srv; /* logon server unicode string */
UNISTR2 uni_logon_dom; /* logon domain unicode string */
- DOM_SID undoc_dom_sids[2]; /* undocumented - domain SIDs */
DOM_SID dom_sid; /* domain SID */
+ DOM_SID other_sids[LSA_MAX_SIDS]; /* undocumented - domain SIDs */
} LSA_USER_INFO;
@@ -750,7 +751,7 @@ typedef struct lsa_r_sam_logon_info
DOM_CRED srv_creds; /* server credentials. server time stamp appears to be ignored. */
uint32 buffer_user;
- LSA_USER_INFO user;
+ LSA_USER_INFO *user;
uint32 auth_resp; /* 1 - Authoritative response; 0 - Non-Auth? */
diff --git a/source/lsaparse.c b/source/lsaparse.c
index 43e7ef1d402..2113b19cd33 100644
--- a/source/lsaparse.c
+++ b/source/lsaparse.c
@@ -403,7 +403,10 @@ char* lsa_io_r_sam_logon(BOOL io, LSA_R_SAM_LOGON *r_l, char *q, char *base, int
q = smb_io_cred(io, &(r_l->srv_creds), q, base, align); /* server credentials. server time stamp appears to be ignored. */
RW_IVAL(io, q, r_l->buffer_user, 0); q += 4;
- q = lsa_io_user_info(io, &(r_l->user), q, base, align);
+ if (r_l->buffer_user != 0)
+ {
+ q = lsa_io_user_info(io, r_l->user, q, base, align);
+ }
RW_IVAL(io, q, r_l->auth_resp, 0); q += 4; /* 1 - Authoritative response; 0 - Non-Auth? */
diff --git a/source/smbd/pipes.c b/source/smbd/pipes.c
index 0fb8a89c9e1..95b69ef4d97 100644
--- a/source/smbd/pipes.c
+++ b/source/smbd/pipes.c
@@ -28,6 +28,7 @@
#include "includes.h"
#include "trans2.h"
+#include "nterr.h"
#define PIPE "\\PIPE\\"
#define PIPELEN strlen(PIPE)
@@ -371,7 +372,7 @@ BOOL api_LsarpcTNP(int cnum,int uid, char *param,char *data,
/* BIG NOTE: this function only does SIDS where the identauth is not >= 2^32 */
/* identauth >= 2^32 can be detected because it will be specified in hex */
-static void init_dom_sid(DOM_SID *sid, char *domsid)
+static void make_dom_sid(DOM_SID *sid, char *domsid)
{
int identauth;
char *p;
@@ -422,7 +423,7 @@ static void create_rpc_reply(RPC_HDR *hdr, uint32 call_id, int data_len)
hdr->reserved = 0; /* reserved */
}
-static void init_rpc_reply(char *inbuf, char *q, char *base, int data_len)
+static void make_rpc_reply(char *inbuf, char *q, char *base, int data_len)
{
uint32 callid = RIVAL(inbuf, 12);
RPC_HDR hdr;
@@ -447,7 +448,14 @@ static int lsa_reply_open_policy(char *q, char *base)
return q - start;
}
-static void init_unistr2(UNISTR2 *str, char *buf, int len, char terminate)
+static void make_uni_hdr(UNIHDR *hdr, int max_len, int len, uint16 terminate)
+{
+ hdr->uni_max_len = max_len;
+ hdr->uni_str_len = len;
+ hdr->undoc = terminate;
+}
+
+static void make_unistr2(UNISTR2 *str, char *buf, int len, char terminate)
{
/* set up string lengths. add one if string is not null-terminated */
str->uni_max_len = len + (terminate != 0 ? 1 : 0);
@@ -461,7 +469,7 @@ static void init_unistr2(UNISTR2 *str, char *buf, int len, char terminate)
str->buffer[len] = (uint16)terminate;
}
-static void init_dom_query(DOM_QUERY *d_q, char *dom_name, char *dom_sid)
+static void make_dom_query(DOM_QUERY *d_q, char *dom_name, char *dom_sid)
{
int domlen = strlen(dom_name);
@@ -473,9 +481,9 @@ static void init_dom_query(DOM_QUERY *d_q, char *dom_name, char *dom_sid)
d_q->buffer_dom_sid = 0; /* domain sid pointer */
/* NOT null-terminated: 4-terminated instead! */
- init_unistr2(&(d_q->uni_domain_name), dom_name, domlen, 4);
+ make_unistr2(&(d_q->uni_domain_name), dom_name, domlen, 4);
- init_dom_sid(&(d_q->dom_sid), dom_sid);
+ make_dom_sid(&(d_q->dom_sid), dom_sid);
}
static int lsa_reply_query_info(LSA_Q_QUERY_INFO *q_q, char *q, char *base,
@@ -489,7 +497,7 @@ static int lsa_reply_query_info(LSA_Q_QUERY_INFO *q_q, char *q, char *base,
r_q.undoc_buffer = 1; /* not null */
r_q.info_class = q_q->info_class;
- init_dom_query(&r_q.dom.id5, dom_name, dom_sid);
+ make_dom_query(&r_q.dom.id5, dom_name, dom_sid);
r_q.status = 0x0;
@@ -500,7 +508,7 @@ static int lsa_reply_query_info(LSA_Q_QUERY_INFO *q_q, char *q, char *base,
return q - start;
}
-static void init_lsa_r_req_chal(LSA_R_REQ_CHAL *r_c, char chal[8], int status)
+static void make_lsa_r_req_chal(LSA_R_REQ_CHAL *r_c, char chal[8], int status)
{
memcpy(r_c->srv_chal.data, chal, sizeof(r_c->srv_chal.data));
r_c->status = status;
@@ -523,7 +531,7 @@ static int lsa_reply_req_chal(LSA_Q_REQ_CHAL *q_c, char *q, char *base,
/* set up the LSA REQUEST CHALLENGE response */
- init_lsa_r_req_chal(&r_c, chal, 0);
+ make_lsa_r_req_chal(&r_c, chal, 0);
/* store the response in the SMB stream */
q = lsa_io_r_req_chal(False, &r_c, q, base, 4);
@@ -532,15 +540,15 @@ static int lsa_reply_req_chal(LSA_Q_REQ_CHAL *q_c, char *q, char *base,
return q - start;
}
-static void init_lsa_chal(DOM_CHAL *cred, char resp_cred[8])
+static void make_lsa_chal(DOM_CHAL *cred, char resp_cred[8])
{
memcpy(cred->data, resp_cred, sizeof(cred->data));
}
-static void init_lsa_r_auth_2(LSA_R_AUTH_2 *r_a,
+static void make_lsa_r_auth_2(LSA_R_AUTH_2 *r_a,
char resp_cred[8], NEG_FLAGS *flgs, int status)
{
- init_lsa_chal(&(r_a->srv_chal), resp_cred);
+ make_lsa_chal(&(r_a->srv_chal), resp_cred);
memcpy(&(r_a->srv_flgs), flgs, sizeof(r_a->srv_flgs));
r_a->status = status;
}
@@ -553,7 +561,7 @@ static int lsa_reply_auth_2(LSA_Q_AUTH_2 *q_a, char *q, char *base,
/* set up the LSA AUTH 2 response */
- init_lsa_r_auth_2(&r_a, resp_cred, &(q_a->clnt_flgs), status);
+ make_lsa_r_auth_2(&r_a, resp_cred, &(q_a->clnt_flgs), status);
/* store the response in the SMB stream */
q = lsa_io_r_auth_2(False, &r_a, q, base, 4);
@@ -562,17 +570,17 @@ static int lsa_reply_auth_2(LSA_Q_AUTH_2 *q_a, char *q, char *base,
return q - start;
}
-static void init_lsa_dom_chal(DOM_CRED *cred, char srv_chal[8], UTIME srv_time)
+static void make_lsa_dom_chal(DOM_CRED *cred, char srv_chal[8], UTIME srv_time)
{
- init_lsa_chal(&(cred->challenge), srv_chal);
+ make_lsa_chal(&(cred->challenge), srv_chal);
cred->timestamp = srv_time;
}
-static void init_lsa_r_srv_pwset(LSA_R_SRV_PWSET *r_a,
+static void make_lsa_r_srv_pwset(LSA_R_SRV_PWSET *r_a,
char srv_chal[8], UTIME srv_time, int status)
{
- init_lsa_dom_chal(&(r_a->srv_cred), srv_chal, srv_time);
+ make_lsa_dom_chal(&(r_a->srv_cred), srv_chal, srv_time);
r_a->status = status;
}
@@ -584,7 +592,7 @@ static int lsa_reply_srv_pwset(LSA_Q_SRV_PWSET *q_s, char *q, char *base,
LSA_R_SRV_PWSET r_s;
/* set up the LSA Server Password Set response */
- init_lsa_r_srv_pwset(&r_s, srv_cred, srv_time, status);
+ make_lsa_r_srv_pwset(&r_s, srv_cred, srv_time, status);
/* store the response in the SMB stream */
q = lsa_io_r_srv_pwset(False, &r_s, q, base, 4);
@@ -593,3 +601,159 @@ static int lsa_reply_srv_pwset(LSA_Q_SRV_PWSET *q_s, char *q, char *base,
return q - start;
}
+static void make_lsa_user_info(LSA_USER_INFO *usr,
+
+ NTTIME *logon_time,
+ NTTIME *logoff_time,
+ NTTIME *kickoff_time,
+ NTTIME *pass_last_set_time,
+ NTTIME *pass_can_change_time,
+ NTTIME *pass_must_change_time,
+
+ char *user_name,
+ char *full_name,
+ char *logon_script,
+ char *profile_path,
+ char *home_dir,
+ char *dir_drive,
+
+ uint16 logon_count,
+ uint16 bad_pw_count,
+
+ uint32 user_id,
+ uint32 group_id,
+ uint32 num_groups,
+ DOM_GID *gids,
+ uint32 user_flgs,
+
+ char sess_key[16],
+
+ char *logon_srv,
+ char *logon_dom,
+
+ char *dom_sid,
+ char *other_sids) /* space-delimited set of SIDs */
+{
+ /* only cope with one "other" sid, right now. */
+ /* need to count the number of space-delimited sids */
+ int i;
+ int num_other_sids = other_sids != NULL ? 1 : 0;
+
+ int len_user_name = strlen(user_name );
+ int len_full_name = strlen(full_name );
+ int len_logon_script = strlen(logon_script);
+ int len_profile_path = strlen(profile_path);
+ int len_home_dir = strlen(home_dir );
+ int len_dir_drive = strlen(dir_drive );
+
+ int len_logon_srv = strlen(logon_srv);
+ int len_logon_dom = strlen(logon_dom);
+
+ usr->undoc_buffer = 1; /* yes, we're bothering to put USER_INFO data here */
+
+ usr->logon_time = *logon_time;
+ usr->logoff_time = *logoff_time;
+ usr->kickoff_time = *kickoff_time;
+ usr->pass_last_set_time = *pass_last_set_time;
+ usr->pass_can_change_time = *pass_can_change_time;
+ usr->pass_must_change_time = *pass_must_change_time;
+
+ make_uni_hdr(&(usr->hdr_user_name ), len_user_name , len_user_name , 4);
+ make_uni_hdr(&(usr->hdr_full_name ), len_full_name , len_full_name , 4);
+ make_uni_hdr(&(usr->hdr_logon_script), len_logon_script, len_logon_script, 4);
+ make_uni_hdr(&(usr->hdr_profile_path), len_profile_path, len_profile_path, 4);
+ make_uni_hdr(&(usr->hdr_home_dir ), len_home_dir , len_home_dir , 4);
+ make_uni_hdr(&(usr->hdr_dir_drive ), len_dir_drive , len_dir_drive , 4);
+
+ usr->logon_count = logon_count;
+ usr->bad_pw_count = bad_pw_count;
+
+ usr->user_id = user_id;
+ usr->group_id = group_id;
+ usr->num_groups = num_groups;
+ usr->buffer_groups = num_groups ? 1 : 0; /* yes, we're bothering to put group info in */
+ usr->user_flgs = user_flgs;
+
+ if (sess_key != NULL)
+ {
+ memcpy(usr->sess_key, sess_key, sizeof(usr->sess_key));
+ }
+ else
+ {
+ bzero(usr->sess_key, sizeof(usr->sess_key));
+ }
+
+ make_uni_hdr(&(usr->hdr_logon_srv), len_logon_srv, len_logon_srv, 4);
+ make_uni_hdr(&(usr->hdr_logon_dom), len_logon_dom, len_logon_dom, 4);
+
+ usr->buffer_dom_id = dom_sid ? 1 : 0; /* yes, we're bothering to put a domain SID in */
+
+ bzero(usr->padding, sizeof(usr->padding));
+
+ usr->num_other_sids = num_other_sids;
+ usr->buffer_other_sids = num_other_sids != 0 ? 1 : 0;
+
+ make_unistr2(&(usr->uni_user_name ), user_name , len_user_name , 0);
+ make_unistr2(&(usr->uni_full_name ), full_name , len_full_name , 0);
+ make_unistr2(&(usr->uni_logon_script), logon_script, len_logon_script, 0);
+ make_unistr2(&(usr->uni_profile_path), profile_path, len_profile_path, 0);
+ make_unistr2(&(usr->uni_home_dir ), home_dir , len_home_dir , 0);
+ make_unistr2(&(usr->uni_dir_drive ), dir_drive , len_dir_drive , 0);
+
+ usr->num_groups2 = num_groups;
+ for (i = 0; i < num_groups; i++)
+ {
+ usr->gids[i] = gids[i];
+ }
+
+ make_unistr2(&(usr->uni_logon_srv), logon_srv, len_logon_srv, 0);
+ make_unistr2(&(usr->uni_logon_dom), logon_dom, len_logon_dom, 0);
+
+ make_dom_sid(&(usr->dom_sid), dom_sid);
+ make_dom_sid(&(usr->other_sids[0]), other_sids);
+}
+
+
+static int lsa_reply_sam_logon(LSA_Q_SAM_LOGON *q_s, char *q, char *base,
+ char srv_cred[8], UTIME srv_time,
+ LSA_USER_INFO *user_info)
+{
+ char *start = q;
+ LSA_R_SAM_LOGON r_s;
+
+ /* XXXX maybe we want to say 'no', reject the client's credentials */
+ r_s.buffer_creds = 1; /* yes, we have valid server credentials */
+ make_lsa_dom_chal(&(r_s.srv_creds), srv_cred, srv_time);
+
+ /* store the user information, if there is any. */
+ r_s.user = user_info;
+ r_s.buffer_user = user_info != NULL ? 1 : 0;
+ r_s.status = user_info != NULL ? 0 : (0xC000000|NT_STATUS_NO_SUCH_USER);
+
+ /* store the response in the SMB stream */
+ q = lsa_io_r_sam_logon(False, &r_s, q, base, 4);
+
+ /* return length of SMB data stored */
+ return q - start;
+}
+
+
+static int lsa_reply_sam_logoff(LSA_Q_SAM_LOGOFF *q_s, char *q, char *base,
+ char srv_cred[8], UTIME srv_time,
+ uint32 status)
+{
+ char *start = q;
+ LSA_R_SAM_LOGOFF r_s;
+
+ /* XXXX maybe we want to say 'no', reject the client's credentials */
+ r_s.buffer_creds = 1; /* yes, we have valid server credentials */
+ make_lsa_dom_chal(&(r_s.srv_creds), srv_cred, srv_time);
+
+ r_s.status = status;
+
+ /* store the response in the SMB stream */
+ q = lsa_io_r_sam_logoff(False, &r_s, q, base, 4);
+
+ /* return length of SMB data stored */
+ return q - start;
+}
--
cgit
From 1e1366ddc5542283a37debdf830ca139bbade1b0 Mon Sep 17 00:00:00 2001
From: Jeremy Allison
Date: Tue, 7 Oct 1997 18:46:19 +0000
Subject: locking.c: Added fix for race condition in slow share mode code.
lsaparse.c: #ifdef'ed out code so this will compile - LUKE PLEASE CHECK THIS.
pipes.c: #ifdef'ed out code so this will compile - LUKE PLEASE CHECK THIS.
server.c: Fixed last known oplock race condition. smb.h: Re-removed
USE_OPLOCK defines - someone checked in an old version. smbparse.c: #ifdef'ed
out code so this will compile - LUKE PLEASE CHECK THIS. Jeremy
(jallison@whistle.com)
---
source/include/smb.h | 15 ----------
source/locking/locking.c | 71 ++++++++++++++++++++++++++++++++++++++----------
source/lsaparse.c | 2 ++
source/smbd/pipes.c | 4 +++
source/smbd/server.c | 29 ++++++++++++++++++++
source/smbparse.c | 2 ++
6 files changed, 93 insertions(+), 30 deletions(-)
diff --git a/source/include/smb.h b/source/include/smb.h
index 3adb3e5a4cb..c347202743c 100644
--- a/source/include/smb.h
+++ b/source/include/smb.h
@@ -1042,10 +1042,8 @@ typedef struct
{
smb_shm_offset_t next_share_mode_entry;
int pid;
-#ifdef USE_OPLOCKS
uint16 op_port;
uint16 op_type;
-#endif /* USE_OPLOCKS */
int share_mode;
struct timeval time;
} share_mode_entry;
@@ -1054,10 +1052,8 @@ typedef struct
typedef struct
{
int pid;
-#ifdef USE_OPLOCKS
uint16 op_port;
uint16 op_type;
-#endif /* USE_OPLOCKS */
int share_mode;
struct timeval time;
} min_share_mode_entry;
@@ -1083,11 +1079,7 @@ struct connect_record
};
#ifndef LOCKING_VERSION
-#ifdef USE_OPLOCKS
#define LOCKING_VERSION 4
-#else /* USE_OPLOCKS */
-#define LOCKING_VERSION 3
-#endif /* USE_OPLOCKS */
#endif /* LOCKING_VERSION */
#if !defined(FAST_SHARE_MODES)
@@ -1103,11 +1095,7 @@ struct connect_record
#define SMF_FILENAME_LEN_OFFSET 8
#define SMF_HEADER_LENGTH 10
-#ifdef USE_OPLOCKS
#define SMF_ENTRY_LENGTH 20
-#else /* USE_OPLOCKS */
-#define SMF_ENTRY_LENGTH 16
-#endif /* USE_OPLOCKS */
/*
* Share mode record offsets.
@@ -1117,11 +1105,8 @@ struct connect_record
#define SME_USEC_OFFSET 4
#define SME_SHAREMODE_OFFSET 8
#define SME_PID_OFFSET 12
-
-#ifdef USE_OPLOCKS
#define SME_PORT_OFFSET 16
#define SME_OPLOCK_TYPE_OFFSET 18
-#endif /* USE_OPLOCKS */
#endif /* FAST_SHARE_MODES */
diff --git a/source/locking/locking.c b/source/locking/locking.c
index 6e321d0626e..639bc7be0ba 100644
--- a/source/locking/locking.c
+++ b/source/locking/locking.c
@@ -25,6 +25,10 @@
May 1997. Jeremy Allison (jallison@whistle.com). Modified share mode
locking to deal with multiple share modes per open file.
+
+ September 1997. Jeremy Allison (jallison@whistle.com). Added oplock
+ support.
+
*/
#include "includes.h"
@@ -726,13 +730,60 @@ BOOL lock_share_entry(int cnum, uint32 dev, uint32 inode, share_lock_token *ptok
{
int old_umask;
+ BOOL gotlock = False;
unbecome_user();
old_umask = umask(0);
+
+ /*
+ * There was a race condition in the original slow share mode code.
+ * A smbd could open a share mode file, and before getting
+ * the lock, another smbd could delete the last entry for
+ * the share mode file and delete the file entry from the
+ * directory. Thus this smbd would be left with a locked
+ * share mode fd attached to a file that no longer had a
+ * directory entry. Thus another smbd would think that
+ * there were no outstanding opens on the file. To fix
+ * this we now check we can do a stat() call on the filename
+ * before allowing the lock to proceed, and back out completely
+ * and try the open again if we cannot.
+ * Jeremy Allison (jallison@whistle.com).
+ */
+
+ do
+ {
+ struct stat dummy_stat;
+
#ifdef SECURE_SHARE_MODES
- fd = (share_lock_token)open(fname,O_RDWR|O_CREAT,0600);
+ fd = (share_lock_token)open(fname,O_RDWR|O_CREAT,0600);
#else /* SECURE_SHARE_MODES */
- fd = (share_lock_token)open(fname,O_RDWR|O_CREAT,0666);
+ fd = (share_lock_token)open(fname,O_RDWR|O_CREAT,0666);
#endif /* SECURE_SHARE_MODES */
+
+ /* At this point we have an open fd to the share mode file.
+ Lock the first byte exclusively to signify a lock. */
+ if(fcntl_lock(fd, F_SETLKW, 0, 1, F_WRLCK) == False)
+ {
+ DEBUG(0,("ERROR lock_share_entry: fcntl_lock on file %s failed with %s\n",
+ fname, strerror(errno)));
+ close(fd);
+ return False;
+ }
+
+ /*
+ * If we cannot stat the filename, the file was deleted between
+ * the open and the lock call. Back out and try again.
+ */
+
+ if(stat(fname, &dummy_stat)!=0)
+ {
+ DEBUG(2,("lock_share_entry: Re-issuing open on %s to fix race. Error was %s\n",
+ fname, strerror(errno)));
+ close(fd);
+ }
+ else
+ gotlock = True;
+ } while(!gotlock);
+
umask(old_umask);
if(!become_user(cnum,Connections[cnum].vuid))
{
@@ -750,18 +801,8 @@ BOOL lock_share_entry(int cnum, uint32 dev, uint32 inode, share_lock_token *ptok
}
}
- /* At this point we have an open fd to the share mode file.
- Lock the first byte exclusively to signify a lock. */
- if(fcntl_lock(fd, F_SETLKW, 0, 1, F_WRLCK) == False)
- {
- DEBUG(0,("ERROR lock_share_entry: fcntl_lock failed with %s\n",
- strerror(errno)));
- close(fd);
- return False;
- }
-
- *ptok = (share_lock_token)fd;
- return True;
+ *ptok = (share_lock_token)fd;
+ return True;
}
/*******************************************************************
@@ -781,7 +822,7 @@ BOOL unlock_share_entry(int cnum, uint32 dev, uint32 inode, share_lock_token tok
ret = False;
}
- close((int)token);
+ close(fd);
return ret;
}
diff --git a/source/lsaparse.c b/source/lsaparse.c
index 2113b19cd33..b1d9d739240 100644
--- a/source/lsaparse.c
+++ b/source/lsaparse.c
@@ -24,6 +24,7 @@
extern int DEBUGLEVEL;
+#if 0 /* NEED TO DO THIS TO GET A COMPILE - LUKE PLEASE CHECK THIS !!! */
/*******************************************************************
reads or writes an LSA_R_OPEN_POL structure.
********************************************************************/
@@ -446,6 +447,7 @@ char* lsa_io_r_sam_logoff(BOOL io, LSA_R_SAM_LOGOFF *r_l, char *q, char *base, i
return q;
}
+#endif /* 0 LUKE PLEASE CHECK !! */
#if 0
/*******************************************************************
reads or writes a structure.
diff --git a/source/smbd/pipes.c b/source/smbd/pipes.c
index 95b69ef4d97..ffa64a4e808 100644
--- a/source/smbd/pipes.c
+++ b/source/smbd/pipes.c
@@ -364,6 +364,8 @@ BOOL api_LsarpcTNP(int cnum,int uid, char *param,char *data,
return(True);
}
+#if 0 /* HAVING TO DO THIS TO GET THINGS TO COMPILE - LUKE PLEASE CHECK THIS !!! */
+
/*
PAXX: Someone fix above.
The above API is indexing RPC calls based on RPC flags and
@@ -757,3 +759,5 @@ static int lsa_reply_sam_logoff(LSA_Q_SAM_LOGOFF *q_s, char *q, char *base,
/* return length of SMB data stored */
return q - start;
}
+
+#endif /* LUKE PLEASE CHECK THIS !! */
diff --git a/source/smbd/server.c b/source/smbd/server.c
index 4f5b01ba91e..92c219c71b3 100644
--- a/source/smbd/server.c
+++ b/source/smbd/server.c
@@ -2455,6 +2455,9 @@ address %x. Error was %s\n", htonl(INADDR_LOOPBACK), strerror(errno)));
}
oplock_port = ntohs(sock_name.sin_port);
+ DEBUG(3,("open_oplock ipc: pid = %d, oplock_port = %u\n",
+ getpid(), oplock_port));
+
return True;
}
@@ -2545,6 +2548,31 @@ pid %d, port %d, for file dev = %x, inode = %x\n", remotepid,
}
break;
+ /*
+ * Keep this as a debug case - eventually we can remove it.
+ */
+ case 0x8001:
+ DEBUG(0,("process_local_message: Received unsolicited break \
+reply - dumping info.\n"));
+
+ if(msg_len != OPLOCK_BREAK_MSG_LEN)
+ {
+ DEBUG(0,("process_local_message: ubr: incorrect length for reply \
+(was %d, should be %d).\n", msg_len, OPLOCK_BREAK_MSG_LEN));
+ return False;
+ }
+
+ {
+ uint32 remotepid = IVAL(msg_start,OPLOCK_BREAK_PID_OFFSET);
+ uint32 dev = IVAL(msg_start,OPLOCK_BREAK_DEV_OFFSET);
+ uint32 inode = IVAL(msg_start, OPLOCK_BREAK_INODE_OFFSET);
+
+ DEBUG(0,("process_local_message: unsolicited oplock break reply from \
+pid %d, port %d, dev = %x, inode = %x\n", remotepid, from_port, dev, inode));
+
+ }
+ return False;
+
default:
DEBUG(0,("process_local_message: unknown UDP message command code (%x) - ignoring.\n",
(unsigned int)SVAL(msg_start,0)));
@@ -2860,6 +2888,7 @@ oplock break response from pid %d on port %d for dev = %x, inode = %x.\n",
share_entry->pid, share_entry->op_port, dev, inode));
if(push_local_message(op_break_reply, sizeof(op_break_reply)) == False)
return False;
+ continue;
}
break;
diff --git a/source/smbparse.c b/source/smbparse.c
index 7ea140f7cb7..ae1f4f4b253 100644
--- a/source/smbparse.c
+++ b/source/smbparse.c
@@ -456,7 +456,9 @@ char* smb_io_dom_query(BOOL io, DOM_QUERY *d_q, char *q, char *base, int align)
if (d_q->buffer_dom_name != 0)
{
+#if 0 /* REMOVED AS WON'T COMPILE AS IS - LUKE PLEASE CHECK !!!!! */
q = smb_io_unistr(io, &(d_q->uni_domain_name), q, base, align); /* domain name (unicode string) */
+#endif
}
if (d_q->buffer_dom_sid != 0)
{
--
cgit
From 1c510a4c3c59ebdf170b73c0fb082d0fa1fabf25 Mon Sep 17 00:00:00 2001
From: Jeremy Allison
Date: Tue, 7 Oct 1997 19:24:44 +0000
Subject: Fixed nasty (but rare) race mode condition with slow share mode code.
Jeremy (jallison@whistle.com)
---
source/locking/locking.c | 64 +++++++++++++++++++++++++++++++++++++-----------
1 file changed, 50 insertions(+), 14 deletions(-)
diff --git a/source/locking/locking.c b/source/locking/locking.c
index 868902963fe..b86ef76a2b8 100644
--- a/source/locking/locking.c
+++ b/source/locking/locking.c
@@ -612,13 +612,59 @@ BOOL lock_share_entry(int cnum, uint32 dev, uint32 inode, share_lock_token *ptok
{
int old_umask;
+ BOOL gotlock = False;
unbecome_user();
old_umask = umask(0);
+
+ /*
+ * There was a race condition in the original slow share mode code.
+ * A smbd could open a share mode file, and before getting
+ * the lock, another smbd could delete the last entry for
+ * the share mode file and delete the file entry from the
+ * directory. Thus this smbd would be left with a locked
+ * share mode fd attached to a file that no longer had a
+ * directory entry. Thus another smbd would think that
+ * there were no outstanding opens on the file. To fix
+ * this we now check we can do a stat() call on the filename
+ * before allowing the lock to proceed, and back out completely
+ * and try the open again if we cannot.
+ * Jeremy Allison (jallison@whistle.com).
+ */
+
+ do
+ {
+ struct stat dummy_stat;
#ifdef SECURE_SHARE_MODES
- fd = (share_lock_token)open(fname,O_RDWR|O_CREAT,0600);
+ fd = (share_lock_token)open(fname,O_RDWR|O_CREAT,0600);
#else /* SECURE_SHARE_MODES */
- fd = (share_lock_token)open(fname,O_RDWR|O_CREAT,0666);
+ fd = (share_lock_token)open(fname,O_RDWR|O_CREAT,0666);
#endif /* SECURE_SHARE_MODES */
+
+ /* At this point we have an open fd to the share mode file.
+ Lock the first byte exclusively to signify a lock. */
+ if(fcntl_lock(fd, F_SETLKW, 0, 1, F_WRLCK) == False)
+ {
+ DEBUG(0,("ERROR lock_share_entry: fcntl_lock failed with %s\n",
+ strerror(errno)));
+ close(fd);
+ return False;
+ }
+
+ /*
+ * If we cannot stat the filename, the file was deleted between
+ * the open and the lock call. Back out and try again.
+ */
+
+ if(stat(fname, &dummy_stat)!=0)
+ {
+ DEBUG(2,("lock_share_entry: Re-issuing open on %s to fix race. Error was %s\n",
+ fname, strerror(errno)));
+ close(fd);
+ }
+ else
+ gotlock = True;
+ } while(!gotlock);
+
umask(old_umask);
if(!become_user(cnum,Connections[cnum].vuid))
{
@@ -636,18 +682,8 @@ BOOL lock_share_entry(int cnum, uint32 dev, uint32 inode, share_lock_token *ptok
}
}
- /* At this point we have an open fd to the share mode file.
- Lock the first byte exclusively to signify a lock. */
- if(fcntl_lock(fd, F_SETLKW, 0, 1, F_WRLCK) == False)
- {
- DEBUG(0,("ERROR lock_share_entry: fcntl_lock failed with %s\n",
- strerror(errno)));
- close(fd);
- return False;
- }
-
- *ptok = (share_lock_token)fd;
- return True;
+ *ptok = (share_lock_token)fd;
+ return True;
}
/*******************************************************************
--
cgit
From 707d0ec388c0045938f367e1d17919bfc8637fea Mon Sep 17 00:00:00 2001
From: "Christopher R. Hertel"
Date: Tue, 7 Oct 1997 22:04:05 +0000
Subject: I rewrote the name_mangle() and name_len(). The interface is the
same, but I've simplified the code a bit and added a few comments. I tested
the changes and the output is the same as that produced by the original (at
least, it was in all of my tests). CRH
---
source/lib/util.c | 111 ++++++++++++++++++++++++++++++++----------------------
1 file changed, 65 insertions(+), 46 deletions(-)
diff --git a/source/lib/util.c b/source/lib/util.c
index 611794c4a86..39d3c61b9e3 100644
--- a/source/lib/util.c
+++ b/source/lib/util.c
@@ -684,48 +684,61 @@ static int name_interpret(char *in,char *out)
/****************************************************************************
mangle a name into netbios format
+
+ Note: must be (33 + strlen(scope) + 2) bytes long, at minimum.
****************************************************************************/
-int name_mangle(char *In,char *Out,char name_type)
-{
- fstring name;
- char buf[20];
- char *in = (char *)&buf[0];
- char *out = (char *)Out;
- char *p, *label;
- int i;
+int name_mangle( char *In, char *Out, char name_type )
+ {
+ int i;
+ int c;
+ int len;
+ char buf[20];
+ char *p = Out;
+
+ /* Safely copy the input string, In, into buf[]. */
+ (void)memset( buf, 0, 20 );
+ if( '*' == In[0] )
+ buf[0] = '*';
+ else
+ (void)sprintf( buf, "%-15.15s%c", In, name_type );
- if (In[0] != '*') {
- StrnCpy(name,In,sizeof(name)-1);
- sprintf(buf,"%-15.15s%c",name,name_type);
- } else {
- buf[0]='*';
- memset(&buf[1],0,16);
- }
+ /* Place the length of the first field into the output buffer. */
+ p[0] = 32;
+ p++;
- *out++ = 32;
- for (i=0;i<16;i++) {
- char c = toupper(in[i]);
- out[i*2] = (c>>4) + 'A';
- out[i*2+1] = (c & 0xF) + 'A';
- }
- out[32]=0;
- out += 32;
-
- label = scope;
- while (*label)
+ /* Now convert the name to the rfc1001/1002 format. */
+ for( i = 0; i < 16; i++ )
{
- p = strchr(label, '.');
- if (p == 0)
- p = label + strlen(label);
- *out++ = p - label;
- memcpy(out, label, p - label);
- out += p - label;
- label += p - label + (*p == '.');
+ c = toupper( buf[i] );
+ p[i*2] = ( (c >> 4) & 0x000F ) + 'A';
+ p[(i*2)+1] = (c & 0x000F) + 'A';
}
- *out = 0;
- return(name_len(Out));
-}
+ p += 32;
+ p[0] = '\0';
+ /* Add the scope string. */
+ for( i = 0, len = 0; NULL != scope; i++, len++ )
+ {
+ switch( scope[i] )
+ {
+ case '\0':
+ p[0] = len;
+ if( len > 0 )
+ p[len+1] = 0;
+ return( name_len(Out) );
+ case '.':
+ p[0] = len;
+ p += (len + 1);
+ len = 0;
+ break;
+ default:
+ p[len+1] = scope[i];
+ break;
+ }
+ }
+
+ return( name_len(Out) );
+ } /* name_mangle */
/*******************************************************************
check if a file exists
@@ -2555,21 +2568,27 @@ int name_extract(char *buf,int ofs,char *name)
strcpy(name,"");
if (d < -50 || d > 50) return(0);
return(name_interpret(p,name));
-}
+}
-
/****************************************************************************
return the total storage length of a mangled name
****************************************************************************/
-int name_len(char *s)
-{
- char *s0=s;
- unsigned char c = *(unsigned char *)s;
- if ((c & 0xC0) == 0xC0)
+int name_len( char *s )
+ {
+ int len;
+
+ /* If the two high bits of the byte are set, return 2. */
+ if( 0xC0 == (*(unsigned char *)s & 0xC0) )
return(2);
- while (*s) s += (*s)+1;
- return(PTR_DIFF(s,s0)+1);
-}
+
+ /* Add up the length bytes. */
+ for( len = 1; (*s); s += (*s) + 1 )
+ {
+ len += *s + 1;
+ }
+
+ return( len );
+ } /* name_len */
/****************************************************************************
send a single packet to a port on another machine
--
cgit
From cc50955a2760f1de7e80b91408a7c0806f6eb44c Mon Sep 17 00:00:00 2001
From: Jeremy Allison
Date: Wed, 8 Oct 1997 00:21:39 +0000
Subject: ipc.c: Added ERROR_MORE_DATA error if client buffer too small.
server.c: Allow admin_user on read only shares. I think this is safe but it
needs looking at. Jeremy (jallison@whistle.com)
---
source/smbd/ipc.c | 2 +-
source/smbd/server.c | 13 +++++++++++--
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/source/smbd/ipc.c b/source/smbd/ipc.c
index b9355c4ec07..6da9562c9f4 100644
--- a/source/smbd/ipc.c
+++ b/source/smbd/ipc.c
@@ -1074,7 +1074,7 @@ static BOOL api_RNetServerEnum(int cnum, uint16 vuid, char *param, char *data,
*rparam_len = 8;
*rparam = REALLOC(*rparam,*rparam_len);
- SSVAL(*rparam,0,NERR_Success);
+ SSVAL(*rparam,0,(missed == 0 ? NERR_Success : ERROR_MORE_DATA));
SSVAL(*rparam,2,0);
SSVAL(*rparam,4,counted);
SSVAL(*rparam,6,counted+missed);
diff --git a/source/smbd/server.c b/source/smbd/server.c
index 92c219c71b3..290181fb9ee 100644
--- a/source/smbd/server.c
+++ b/source/smbd/server.c
@@ -3167,8 +3167,17 @@ int make_connection(char *service,char *user,char *password, int pwlen, char *de
}
/* admin user check */
- if (user_in_list(user,lp_admin_users(snum)) &&
- !pcon->read_only)
+
+ /* JRA - original code denied admin user if the share was
+ marked read_only. Changed as I don't think this is needed,
+ but old code left in case there is a problem here.
+ */
+ if (user_in_list(user,lp_admin_users(snum))
+#if 0
+ && !pcon->read_only)
+#else
+ )
+#endif
{
pcon->admin_user = True;
DEBUG(0,("%s logged in as admin user (root privileges)\n",user));
--
cgit
From 6e1164b7c55668ebd0b6e97d7f05409134b39c1f Mon Sep 17 00:00:00 2001
From: Jeremy Allison
Date: Wed, 8 Oct 1997 00:24:38 +0000
Subject: Added ERROR_MORE_DATA fix when replies have been truncated. Jeremy
(jallison@whistle.com)
---
source/smbd/ipc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source/smbd/ipc.c b/source/smbd/ipc.c
index 9aaf03e6c4f..a0a4ec8fc73 100644
--- a/source/smbd/ipc.c
+++ b/source/smbd/ipc.c
@@ -1074,7 +1074,7 @@ static BOOL api_RNetServerEnum(int cnum, uint16 vuid, char *param, char *data,
*rparam_len = 8;
*rparam = REALLOC(*rparam,*rparam_len);
- SSVAL(*rparam,0,NERR_Success);
+ SSVAL(*rparam,0,(missed == 0 ? NERR_Success : ERROR_MORE_DATA));
SSVAL(*rparam,2,0);
SSVAL(*rparam,4,counted);
SSVAL(*rparam,6,counted+missed);
--
cgit
From 07b878e2027539b6721f41b9f5670d50d9da7071 Mon Sep 17 00:00:00 2001
From: Andrew Tridgell
Date: Wed, 8 Oct 1997 02:18:45 +0000
Subject: put this in 1.9.17 also ...
change the semantics of hosts allow/hosts deny so that a global
setting applies to all shares regardless of any settings on other
shares. This allows us to immediately drop a connection if it does not
come from a allowed host, without even parsing the first SMB
packet. The next time we get a nasty security hole we can offer people
the option of just setting their hosts allow line.
If we drop a connection in this way we generate a "Not listening for
calling name" response and then exit.
---
docs/manpages/smb.conf.5 | 9 +++++----
source/smbd/server.c | 17 +++++++++++++++++
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/docs/manpages/smb.conf.5 b/docs/manpages/smb.conf.5
index a0a96f26ff6..5c4ce3375fe 100644
--- a/docs/manpages/smb.conf.5
+++ b/docs/manpages/smb.conf.5
@@ -720,10 +720,11 @@ then the "load printers" option is easier.
A synonym for this parameter is 'hosts allow'.
This parameter is a comma delimited set of hosts which are permitted to access
-a services. If specified in the [global] section, matching hosts will be
-allowed access to any service that does not specifically exclude them from
-access. Specific services my have their own list, which override those
-specified in the [global] section.
+a service.
+
+If specified in the [global] section then it will apply to all
+services, regardless of whether the individual service has a different
+setting.
You can specify the hosts by name or IP number. For example, you could
restrict access to only the hosts on a Class C subnet with something like
diff --git a/source/smbd/server.c b/source/smbd/server.c
index 2bc0e023158..35a7c730be4 100644
--- a/source/smbd/server.c
+++ b/source/smbd/server.c
@@ -4068,6 +4068,23 @@ static void process(void)
}
}
+ if (trans_num == 0) {
+ /* 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(-1)) {
+ /* send a negative session response "not listining
+ on calling name" */
+ static unsigned char buf[5] = {0x83, 0, 0, 1, 0x81};
+ DEBUG(1,("%s Connection denied from %s\n",
+ timestring(),client_addr()));
+ send_smb(Client,(char *)buf);
+ exit_server("connection denied");
+ }
+ }
+
+
msg_type = CVAL(InBuffer,0);
msg_flags = CVAL(InBuffer,1);
type = CVAL(InBuffer,smb_com);
--
cgit
From 0b7049fae25957851a7f33d2bd500d8ecefc1ad5 Mon Sep 17 00:00:00 2001
From: Luke Leighton
Date: Wed, 8 Oct 1997 11:47:46 +0000
Subject: updating lsaparse.c and smbparse.c in line with changes to pipes.c
and smb.h from yesterday.
---
source/lsaparse.c | 17 ++++++++---------
source/smbd/pipes.c | 4 ----
source/smbparse.c | 4 +---
3 files changed, 9 insertions(+), 16 deletions(-)
diff --git a/source/lsaparse.c b/source/lsaparse.c
index b1d9d739240..4b5c4f586a2 100644
--- a/source/lsaparse.c
+++ b/source/lsaparse.c
@@ -24,7 +24,6 @@
extern int DEBUGLEVEL;
-#if 0 /* NEED TO DO THIS TO GET A COMPILE - LUKE PLEASE CHECK THIS !!! */
/*******************************************************************
reads or writes an LSA_R_OPEN_POL structure.
********************************************************************/
@@ -298,7 +297,7 @@ char* lsa_io_r_srv_pwset(BOOL io, LSA_R_SRV_PWSET *r_s, char *q, char *base, int
q = align_offset(q, base, align);
- q = smb_io_chal(io, &(r_s->srv_chal), q, base, align); /* server challenge */
+ q = smb_io_cred(io, &(r_s->srv_cred), q, base, align); /* server challenge */
RW_IVAL(io, q, r_s->status, 0); q += 4;
@@ -351,8 +350,8 @@ char* lsa_io_user_info(BOOL io, LSA_USER_INFO *usr, char *q, char *base, int ali
RW_IVAL(io, q, usr->buffer_dom_id, 0); q += 4; /* undocumented logon domain id pointer */
RW_PCVAL(io, q, usr->padding, 40); q += 40; /* unused padding bytes? */
- RW_IVAL(io, q, usr->num_sids, 0); q += 4; /* 0 - num_sids */
- RW_IVAL(io, q, usr->buffer_sids, 0); q += 4; /* NULL - undocumented pointer to SIDs. */
+ RW_IVAL(io, q, usr->num_other_sids, 0); q += 4; /* 0 - num_sids */
+ RW_IVAL(io, q, usr->buffer_other_sids, 0); q += 4; /* NULL - undocumented pointer to SIDs. */
q = smb_io_unistr2(io, &(usr->uni_user_name) , q, base, align); /* username unicode string */
q = smb_io_unistr2(io, &(usr->uni_full_name) , q, base, align); /* user's full name unicode string */
@@ -370,10 +369,13 @@ char* lsa_io_user_info(BOOL io, LSA_USER_INFO *usr, char *q, char *base, int ali
q = smb_io_unistr2(io, &( usr->uni_logon_srv), q, base, align); /* logon server unicode string */
q = smb_io_unistr2(io, &( usr->uni_logon_dom), q, base, align); /* logon domain unicode string */
- q = smb_io_dom_sid(io, &(usr->undoc_dom_sids[0]), q, base, align); /* undocumented - domain SIDs */
- q = smb_io_dom_sid(io, &(usr->undoc_dom_sids[1]), q, base, align); /* undocumented - domain SIDs */
q = smb_io_dom_sid(io, &(usr->dom_sid), q, base, align); /* domain SID */
+ for (i = 0; i < usr->num_other_sids; i++)
+ {
+ q = smb_io_dom_sid(io, &(usr->other_sids[i]), q, base, align); /* other domain SIDs */
+ }
+
return q;
}
@@ -447,7 +449,6 @@ char* lsa_io_r_sam_logoff(BOOL io, LSA_R_SAM_LOGOFF *r_l, char *q, char *base, i
return q;
}
-#endif /* 0 LUKE PLEASE CHECK !! */
#if 0
/*******************************************************************
reads or writes a structure.
@@ -463,5 +464,3 @@ reads or writes a structure.
return q;
}
#endif
-
-
diff --git a/source/smbd/pipes.c b/source/smbd/pipes.c
index ffa64a4e808..95b69ef4d97 100644
--- a/source/smbd/pipes.c
+++ b/source/smbd/pipes.c
@@ -364,8 +364,6 @@ BOOL api_LsarpcTNP(int cnum,int uid, char *param,char *data,
return(True);
}
-#if 0 /* HAVING TO DO THIS TO GET THINGS TO COMPILE - LUKE PLEASE CHECK THIS !!! */
-
/*
PAXX: Someone fix above.
The above API is indexing RPC calls based on RPC flags and
@@ -759,5 +757,3 @@ static int lsa_reply_sam_logoff(LSA_Q_SAM_LOGOFF *q_s, char *q, char *base,
/* return length of SMB data stored */
return q - start;
}
-
-#endif /* LUKE PLEASE CHECK THIS !! */
diff --git a/source/smbparse.c b/source/smbparse.c
index ae1f4f4b253..0d93c2e8ad5 100644
--- a/source/smbparse.c
+++ b/source/smbparse.c
@@ -456,9 +456,7 @@ char* smb_io_dom_query(BOOL io, DOM_QUERY *d_q, char *q, char *base, int align)
if (d_q->buffer_dom_name != 0)
{
-#if 0 /* REMOVED AS WON'T COMPILE AS IS - LUKE PLEASE CHECK !!!!! */
- q = smb_io_unistr(io, &(d_q->uni_domain_name), q, base, align); /* domain name (unicode string) */
-#endif
+ q = smb_io_unistr2(io, &(d_q->uni_domain_name), q, base, align); /* domain name (unicode string) */
}
if (d_q->buffer_dom_sid != 0)
{
--
cgit
From d15aed8a9c58a7cc90befaee2d5a2752708f9327 Mon Sep 17 00:00:00 2001
From: Luke Leighton
Date: Wed, 8 Oct 1997 17:12:07 +0000
Subject: loadparm.c proto.h:
added lp_domainsid()
lsaparse.c smb.h:
debugging structures and parsing functions
pipes.c:
finally got to the functions that will go into the RPC switch statement.
---
source/include/proto.h | 5 +-
source/include/smb.h | 4 +-
source/lsaparse.c | 2 +
source/param/loadparm.c | 4 ++
source/smbd/pipes.c | 140 +++++++++++++++++++++++++++++++++++++++++++++++-
5 files changed, 150 insertions(+), 5 deletions(-)
diff --git a/source/include/proto.h b/source/include/proto.h
index 8f8ec5aa8a1..fab69de3d1a 100644
--- a/source/include/proto.h
+++ b/source/include/proto.h
@@ -152,6 +152,7 @@ char *lp_socket_address(void);
char *lp_nis_home_map_name(void);
char *lp_announce_version(void);
char *lp_netbios_aliases(void);
+char *lp_domainsid(void);
BOOL lp_dns_proxy(void);
BOOL lp_wins_support(void);
BOOL lp_wins_proxy(void);
@@ -928,7 +929,7 @@ BOOL in_group(gid_t group, int current_gid, int ngroups, int *groups);
char *StrCpy(char *dest,char *src);
char *StrnCpy(char *dest,char *src,int n);
void putip(void *dest,void *src);
-int name_mangle(char *In,char *Out,char name_type);
+int name_mangle( char *In, char *Out, char name_type );
BOOL file_exist(char *fname,struct stat *sbuf);
time_t file_modtime(char *fname);
BOOL directory_exist(char *dname,struct stat *st);
@@ -989,7 +990,7 @@ BOOL receive_message_or_smb(int smbfd, int oplock_fd,
BOOL send_smb(int fd,char *buffer);
char *name_ptr(char *buf,int ofs);
int name_extract(char *buf,int ofs,char *name);
-int name_len(char *s);
+int name_len( char *s );
BOOL send_one_packet(char *buf,int len,struct in_addr ip,int port,int type);
void msleep(int t);
BOOL in_list(char *s,char *list,BOOL casesensitive);
diff --git a/source/include/smb.h b/source/include/smb.h
index c347202743c..9f5279fca00 100644
--- a/source/include/smb.h
+++ b/source/include/smb.h
@@ -326,6 +326,7 @@ typedef struct domsid2_info
{
uint32 type; /* value is 5 */
uint32 undoc; /* value is 0 */
+
UNIHDR2 hdr; /* XXXX conflict between hdr and str for length */
UNISTR str; /* XXXX conflict between hdr and str for length */
@@ -488,7 +489,8 @@ typedef struct lsa_r_open_pol_info
/* LSA_Q_QUERY_INFO - LSA query info policy */
typedef struct lsa_query_info
{
- uint16 info_class; /* info class (also a policy handle?) */
+ LSA_POL_HND pol; /* policy handle */
+ uint16 info_class; /* info class */
} LSA_Q_QUERY_INFO;
diff --git a/source/lsaparse.c b/source/lsaparse.c
index 4b5c4f586a2..9ea6f566b23 100644
--- a/source/lsaparse.c
+++ b/source/lsaparse.c
@@ -45,6 +45,8 @@ char* lsa_io_q_query(BOOL io, LSA_Q_QUERY_INFO *q_q, char *q, char *base, int al
{
if (q_q == NULL) return NULL;
+ q = smb_io_pol_hnd(io, &(q_q->pol), q, base, align);
+
RW_SVAL(io, q, q_q->info_class, 0); q += 2;
return q;
diff --git a/source/param/loadparm.c b/source/param/loadparm.c
index fb656aa627f..edc2d2b65f6 100644
--- a/source/param/loadparm.c
+++ b/source/param/loadparm.c
@@ -140,6 +140,7 @@ typedef struct
char *szNISHomeMapName;
char *szAnnounceVersion; /* This is initialised in init_globals */
char *szNetbiosAliases;
+ char *szDomainSID;
int max_log_size;
int mangled_stack;
int max_xmit;
@@ -436,6 +437,7 @@ struct parm_struct
{"passwd chat", P_STRING, P_GLOBAL, &Globals.szPasswdChat, NULL},
{"valid chars", P_STRING, P_GLOBAL, &Globals.szValidChars, handle_valid_chars},
{"workgroup", P_USTRING, P_GLOBAL, &Globals.szWorkGroup, NULL},
+ {"domain sid", P_USTRING, P_GLOBAL, &Globals.szDomainSID, NULL},
{"domain controller",P_STRING, P_GLOBAL, &Globals.szDomainController,NULL},
{"username map", P_STRING, P_GLOBAL, &Globals.szUsernameMap, NULL},
{"character set", P_STRING, P_GLOBAL, &Globals.szCharacterSet, handle_character_set},
@@ -839,6 +841,8 @@ FN_GLOBAL_STRING(lp_nis_home_map_name,&Globals.szNISHomeMapName)
FN_GLOBAL_STRING(lp_announce_version,&Globals.szAnnounceVersion)
FN_GLOBAL_STRING(lp_netbios_aliases,&Globals.szNetbiosAliases)
+FN_GLOBAL_STRING(lp_domainsid,&Globals.szDomainSID)
+
FN_GLOBAL_BOOL(lp_dns_proxy,&Globals.bDNSproxy)
FN_GLOBAL_BOOL(lp_wins_support,&Globals.bWINSsupport)
FN_GLOBAL_BOOL(lp_wins_proxy,&Globals.bWINSproxy)
diff --git a/source/smbd/pipes.c b/source/smbd/pipes.c
index 95b69ef4d97..06b785bd873 100644
--- a/source/smbd/pipes.c
+++ b/source/smbd/pipes.c
@@ -423,13 +423,13 @@ static void create_rpc_reply(RPC_HDR *hdr, uint32 call_id, int data_len)
hdr->reserved = 0; /* reserved */
}
-static void make_rpc_reply(char *inbuf, char *q, char *base, int data_len)
+static void make_rpc_reply(char *inbuf, char *q, int data_len)
{
uint32 callid = RIVAL(inbuf, 12);
RPC_HDR hdr;
create_rpc_reply(&hdr, callid, data_len);
- smb_io_rpc_hdr(False, &hdr, q, base, 4);
+ smb_io_rpc_hdr(False, &hdr, q, q, 4);
}
static int lsa_reply_open_policy(char *q, char *base)
@@ -455,6 +455,18 @@ static void make_uni_hdr(UNIHDR *hdr, int max_len, int len, uint16 terminate)
hdr->undoc = terminate;
}
+static void make_uni_hdr2(UNIHDR2 *hdr, int max_len, int len, uint16 terminate)
+{
+ make_uni_hdr(&(hdr->unihdr), max_len, len, terminate);
+ hdr->undoc_buffer = len > 0 ? 1 : 0;
+}
+
+static void make_unistr(UNISTR *str, char *buf)
+{
+ /* store the string (null-terminated copy) */
+ PutUniCode((char *)(str->buffer), buf);
+}
+
static void make_unistr2(UNISTR2 *str, char *buf, int len, char terminate)
{
/* set up string lengths. add one if string is not null-terminated */
@@ -469,6 +481,16 @@ static void make_unistr2(UNISTR2 *str, char *buf, int len, char terminate)
str->buffer[len] = (uint16)terminate;
}
+static void make_dom_sid2(DOM_SID2 *sid2, char *sid_str)
+{
+ int len_sid_str = strlen(sid_str);
+
+ sid2->type = 0x5;
+ sid2->undoc = 0;
+ make_uni_hdr2(&(sid2->hdr), len_sid_str, len_sid_str, 0);
+ make_unistr (&(sid2->str), sid_str);
+}
+
static void make_dom_query(DOM_QUERY *d_q, char *dom_name, char *dom_sid)
{
int domlen = strlen(dom_name);
@@ -508,6 +530,79 @@ static int lsa_reply_query_info(LSA_Q_QUERY_INFO *q_q, char *q, char *base,
return q - start;
}
+/* pretty much hard-coded choice of "other" sids, unfortunately... */
+static void make_dom_ref(DOM_R_REF *ref,
+ char *dom_name, char *dom_sid,
+ char *other_sid1, char *other_sid2, char *other_sid3)
+{
+ int len_dom_name = strlen(dom_name);
+ int len_other_sid1 = strlen(other_sid1);
+ int len_other_sid2 = strlen(other_sid2);
+ int len_other_sid3 = strlen(other_sid3);
+
+ ref->undoc_buffer = 1;
+ ref->num_ref_doms_1 = 4;
+ ref->buffer_dom_name = 1;
+ ref->max_entries = 32;
+ ref->num_ref_doms_2 = 4;
+
+ make_uni_hdr2(&(ref->hdr_dom_name ), len_dom_name , len_dom_name , 0);
+ make_uni_hdr2(&(ref->hdr_ref_dom[0]), len_other_sid1, len_other_sid1, 0);
+ make_uni_hdr2(&(ref->hdr_ref_dom[1]), len_other_sid2, len_other_sid2, 0);
+ make_uni_hdr2(&(ref->hdr_ref_dom[2]), len_other_sid3, len_other_sid3, 0);
+
+ if (dom_name != NULL)
+ {
+ make_unistr(&(ref->uni_dom_name), dom_name);
+ }
+
+ make_dom_sid(&(ref->ref_dom[0]), dom_sid );
+ make_dom_sid(&(ref->ref_dom[1]), other_sid1);
+ make_dom_sid(&(ref->ref_dom[2]), other_sid2);
+ make_dom_sid(&(ref->ref_dom[3]), other_sid3);
+}
+
+static void make_reply_lookup_sids(LSA_R_LOOKUP_SIDS *r_l,
+ int num_entries, char *dom_sids[MAX_LOOKUP_SIDS],
+ char *dom_name, char *dom_sid,
+ char *other_sid1, char *other_sid2, char *other_sid3)
+{
+ int i;
+
+ make_dom_ref(&(r_l->dom_ref), dom_name, dom_sid,
+ other_sid1, other_sid2, other_sid3);
+
+ r_l->num_entries = num_entries;
+ r_l->undoc_buffer = 1;
+ r_l->num_entries2 = num_entries;
+
+ for (i = 0; i < num_entries; i++)
+ {
+ make_dom_sid2(&(r_l->dom_sid[i]), dom_sids[i]);
+ }
+
+ r_l->num_entries3 = num_entries;
+}
+
+static int lsa_reply_lookup_sids(LSA_Q_LOOKUP_SIDS *q_l, char *q, char *base,
+ char *dom_name, char *dom_sid,
+ char *other_sid1, char *other_sid2, char *other_sid3)
+{
+ char *start = q;
+ LSA_R_LOOKUP_SIDS r_l;
+
+ /* set up the LSA Lookup SIDs response */
+ make_reply_lookup_sids(&r_l, 0, NULL, /* q_l->num_entries, q_l->dom_sids, */
+ dom_name, dom_sid, other_sid1, other_sid2, other_sid3);
+ r_l.status = 0x0;
+
+ /* store the response in the SMB stream */
+ q = lsa_io_r_lookup_sids(False, &r_l, q, base, 4);
+
+ /* return length of SMB data stored */
+ return q - start;
+}
+
static void make_lsa_r_req_chal(LSA_R_REQ_CHAL *r_c, char chal[8], int status)
{
memcpy(r_c->srv_chal.data, chal, sizeof(r_c->srv_chal.data));
@@ -757,3 +852,44 @@ static int lsa_reply_sam_logoff(LSA_Q_SAM_LOGOFF *q_s, char *q, char *base,
/* return length of SMB data stored */
return q - start;
}
+
+
+static void api_lsa_open_policy( char *param, char *data,
+ char **rdata, int *rdata_len )
+{
+ int reply_len;
+
+ /* we might actually want to decode the query, but it's not necessary */
+ /* lsa_io_q_open_policy(...); */
+
+ /* return a 20 byte policy handle */
+ reply_len = lsa_reply_open_policy(*rdata + 0x18, *rdata + 0x18);
+
+ /* construct header, now that we know the reply length */
+ make_rpc_reply(data, *rdata, reply_len);
+ *rdata_len = reply_len + 0x18;
+}
+
+static void api_lsa_query_info( char *param, char *data,
+ char **rdata, int *rdata_len )
+{
+ int reply_len;
+
+ LSA_Q_QUERY_INFO q_i;
+ pstring dom_name;
+ pstring dom_sid;
+
+ /* grab the info class and policy handle */
+ lsa_io_q_query(True, &q_i, data + 0x18, data + 0x18, 4);
+
+ pstrcpy(dom_name, lp_workgroup());
+ pstrcpy(dom_sid , lp_domainsid());
+
+ /* construct reply. return status is always 0x0 */
+ reply_len = lsa_reply_query_info(&q_i, *rdata + 0x18, *rdata + 0x18,
+ dom_name, dom_sid);
+
+ /* construct header, now that we know the reply length */
+ make_rpc_reply(data, *rdata, reply_len);
+ *rdata_len = reply_len + 0x18;
+}
--
cgit
From 35dd48740d8f733e7725813322b094b4679b31c5 Mon Sep 17 00:00:00 2001
From: Luke Leighton
Date: Wed, 8 Oct 1997 18:36:34 +0000
Subject: added api_lsa_lookup_sids() function
---
source/smbd/pipes.c | 1074 ++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 1071 insertions(+), 3 deletions(-)
diff --git a/source/smbd/pipes.c b/source/smbd/pipes.c
index 06b785bd873..88cf0b2d713 100644
--- a/source/smbd/pipes.c
+++ b/source/smbd/pipes.c
@@ -370,6 +370,29 @@ BOOL api_LsarpcTNP(int cnum,int uid, char *param,char *data,
fragment length. I've decided to do it based on operation number :-)
*/
+/* BIG NOTE: this function only does SIDS where the identauth is not >= 2^32 */
+char *dom_sid_to_string(DOM_SID *sid)
+{
+ static pstring sidstr;
+ char subauth[16];
+ int i;
+ uint32 ia = (sid->id_auth[0]) +
+ (sid->id_auth[1] << 8 ) +
+ (sid->id_auth[2] << 16) +
+ (sid->id_auth[3] << 24);
+
+ sprintf(sidstr, "S-%d-%d", sid->sid_no, ia);
+
+ for (i = 0; i < sid->num_auths; i++)
+ {
+ sprintf(subauth, "-%d", sid->sub_auths[i]);
+ strcat(sidstr, subauth);
+ }
+
+ DEBUG(5,("dom_sid_to_string returning %s\n", sidstr));
+ return sidstr;
+}
+
/* BIG NOTE: this function only does SIDS where the identauth is not >= 2^32 */
/* identauth >= 2^32 can be detected because it will be specified in hex */
static void make_dom_sid(DOM_SID *sid, char *domsid)
@@ -563,7 +586,7 @@ static void make_dom_ref(DOM_R_REF *ref,
}
static void make_reply_lookup_sids(LSA_R_LOOKUP_SIDS *r_l,
- int num_entries, char *dom_sids[MAX_LOOKUP_SIDS],
+ int num_entries, fstring dom_sids[MAX_LOOKUP_SIDS],
char *dom_name, char *dom_sid,
char *other_sid1, char *other_sid2, char *other_sid3)
{
@@ -584,7 +607,8 @@ static void make_reply_lookup_sids(LSA_R_LOOKUP_SIDS *r_l,
r_l->num_entries3 = num_entries;
}
-static int lsa_reply_lookup_sids(LSA_Q_LOOKUP_SIDS *q_l, char *q, char *base,
+static int lsa_reply_lookup_sids(char *q, char *base,
+ int num_entries, fstring dom_sids[MAX_LOOKUP_SIDS],
char *dom_name, char *dom_sid,
char *other_sid1, char *other_sid2, char *other_sid3)
{
@@ -592,7 +616,7 @@ static int lsa_reply_lookup_sids(LSA_Q_LOOKUP_SIDS *q_l, char *q, char *base,
LSA_R_LOOKUP_SIDS r_l;
/* set up the LSA Lookup SIDs response */
- make_reply_lookup_sids(&r_l, 0, NULL, /* q_l->num_entries, q_l->dom_sids, */
+ make_reply_lookup_sids(&r_l, num_entries, dom_sids,
dom_name, dom_sid, other_sid1, other_sid2, other_sid3);
r_l.status = 0x0;
@@ -893,3 +917,1047 @@ static void api_lsa_query_info( char *param, char *data,
make_rpc_reply(data, *rdata, reply_len);
*rdata_len = reply_len + 0x18;
}
+
+static void api_lsa_lookup_sids( char *param, char *data,
+ char **rdata, int *rdata_len )
+{
+ int reply_len;
+
+ int i;
+ LSA_Q_LOOKUP_SIDS q_l;
+ pstring dom_name;
+ pstring dom_sid;
+ fstring dom_sids[MAX_LOOKUP_SIDS];
+
+ /* grab the info class and policy handle */
+ lsa_io_q_lookup_sids(True, &q_l, data + 0x18, data + 0x18, 4);
+
+ pstrcpy(dom_name, lp_workgroup());
+ pstrcpy(dom_sid , lp_domainsid());
+
+ /* convert received SIDs to strings, so we can do them. */
+ for (i = 0; i < q_l.num_entries; i++)
+ {
+ fstrcpy(dom_sids[i], dom_sid_to_string(&(q_l.dom_sids[i])));
+ }
+
+ /* construct reply. return status is always 0x0 */
+ reply_len = lsa_reply_lookup_sids(*rdata + 0x18, *rdata + 0x18,
+ q_l.num_entries, dom_sids, /* text-converted SIDs */
+ dom_name, dom_sid, /* domain name, domain SID */
+ "S-1-1", "S-1-3", "S-1-5"); /* the three other SIDs */
+
+ /* construct header, now that we know the reply length */
+ make_rpc_reply(data, *rdata, reply_len);
+ *rdata_len = reply_len + 0x18;
+}
+
+
+#ifdef UNDEFINED_NTDOMAIN
+/*
+ PAXX: Someone fix above.
+ The above API is indexing RPC calls based on RPC flags and
+ fragment length. I've decided to do it based on operation number :-)
+*/
+
+BOOL api_ntlsarpcTNP(int cnum,int uid, char *param,char *data,
+ int mdrcnt,int mprcnt,
+ char **rdata,char **rparam,
+ int *rdata_len,int *rparam_len)
+{
+ uint16 opnum;
+ char *q;
+ char *domainname;
+ int domlen;
+ pstring domsid;
+ char *p;
+ int numsubauths;
+ int subauths[MAXSUBAUTHS];
+ struct smb_passwd *smb_pass; /* To check if machine account exists */
+ pstring machacct;
+ pstring foo;
+ uint16 infoclass;
+ uint16 revision; /* Domain sid revision */
+ int identauth;
+ int i;
+ char *logonsrv;
+ char *unicomp;
+ char *accountname;
+ uint16 secchanneltype;
+ uint32 negflags;
+ char netcred[8];
+ uint32 rcvcred[8];
+ char rtncred[8];
+ uint32 clnttime;
+ uint32 rtntime;
+ char *newpass;
+ uint16 logonlevel;
+ uint16 switchval;
+ uint16 dommaxlen;
+ uint16 paramcontrol;
+ uint32 logonid[2];
+ uint16 usernamelen;
+ uint16 usernamemaxlen;
+ uint16 wslen;
+ uint16 wsmaxlen;
+ uchar *rc4lmowfpass;
+ uchar *rc4ntowfpass;
+ char *domain;
+ char *username;
+ char *ws;
+ struct uinfo *userinfo;
+ int pkttype;
+ ArcfourContext c;
+ uchar rc4key[16];
+ uchar ntowfpass[16];
+ uint32 nentries;
+ char *policyhandle;
+ #define MAXSIDS 64
+ uchar *sids[MAXSIDS]; /* for lookup SID */
+ int nsids;
+ int nnames;
+ #define MAXNAMES 64
+ uchar *names[MAXNAMES];
+
+ opnum = SVAL(data,22);
+
+ pkttype = CVAL(data, 2);
+ if (pkttype == 0x0b) /* RPC BIND */
+ {
+ DEBUG(4,("netlogon rpc bind %x\n",pkttype));
+ LsarpcTNP1(data,rdata,rdata_len);
+ return True;
+ }
+
+ DEBUG(4,("ntlsa TransactNamedPipe op %x\n",opnum));
+ initrpcreply(data, *rdata);
+ DEBUG(4,("netlogon LINE %d\n",__LINE__));
+ switch (opnum)
+ {
+ case LSAOPENPOLICY:
+ DEBUG(1,("LSAOPENPOLICY\n"));
+ DEBUG(4,("netlogon LINE %d %lx\n",__LINE__, q));
+ DEBUG(4,("netlogon data %lx\n", data));
+ q = *rdata + 0x18;
+ DEBUG(4,("netlogon LINE %d %lx\n",__LINE__, q));
+ /* return a 20 byte policy handle */
+ /* here's a pretty handle:- */
+ qSIVAL(time(NULL));
+ qSIVAL(0x810a792f);
+ qSIVAL(0x11d107d5);
+ qSIVAL(time(NULL));
+ qSIVAL(0x6cbcf800);
+ DEBUG(4,("netlogon LINE %d %lx\n",__LINE__, q));
+ endrpcreply(data, *rdata, q-*rdata, 0, rdata_len); /* size of data plus return code */
+ DEBUG(4,("netlogon LINE %d %lx\n",__LINE__, q));
+ break;
+
+ case LSAQUERYINFOPOLICY:
+ DEBUG(1,("LSAQUERYINFOPOLICY\n"));
+ dump_data(1,data,128);
+ infoclass = SVAL(data, 44); /* also a policy handle but who cares? */
+ q = *rdata + 0x18;
+ qRSIVAL(0x00000022); /* undocumented. Usually a buffer pointer whose
+ value is ignored */
+ qSSVAL(infoclass);
+ domainname = lp_workgroup();
+ domlen = strlen(domainname);
+ strcpy(domsid,lp_domainsid());
+ DEBUG(4,("netlogon LINE %d %lx %s\n",__LINE__, q, domsid));
+ /* assume, but should check, that domsid starts "S-" */
+ p = strtok(domsid+2,"-");
+ revision = atoi(p);
+ DEBUG(4,("netlogon LINE %d %lx %s rev %d\n",__LINE__, q, p, revision));
+ identauth = atoi(strtok(0,"-"));
+ DEBUG(4,("netlogon LINE %d %lx %s ia %d\n",__LINE__, q, p, identauth));
+ numsubauths = 0;
+ while (p = strtok(0, "-"))
+ subauths[numsubauths++] = atoi(p);
+ DEBUG(4,("netlogon LINE %d %lx\n",__LINE__, q));
+
+ switch (infoclass)
+ {
+ case 5:
+ case 3:
+ default:
+ qSSVAL(0); /* 2 undocumented bytes */
+ qSSVAL(domlen*2);
+ qSSVAL(domlen*2); /* unicode domain len and maxlen */
+ qSIVAL(4); /* domain buffer pointer */
+ qSIVAL(2); /* domain sid pointer */
+ qunistr(domainname);
+ qSIVAL(numsubauths);
+ qSCVAL(revision);
+ qSCVAL(numsubauths);
+ qRSSVAL(0); /* PAXX: FIX! first 2 bytes identifier authority */
+ qRSIVAL(identauth); /* next 4 bytes */
+ for (i = 0; i < numsubauths; i++)
+ {
+ qSIVAL(subauths[i]);
+ }
+ }
+ endrpcreply(data, *rdata, q-*rdata, 0, rdata_len);
+ break;
+
+ case LSAENUMTRUSTDOM:
+ DEBUG(1,("LSAENUMTRUSTDOM\n"));
+ q = *rdata + 0x18;
+ qSIVAL(0); /* enumeration context */
+ qSIVAL(0); /* entries read */
+ qSIVAL(0); /* trust information */
+ endrpcreply(data, *rdata, q-*rdata, 0x8000001a, rdata_len);
+ break;
+
+ case LSACLOSE:
+ DEBUG(1,("LSACLOSE\n"));
+ q = *rdata + 0x18;
+ qSIVAL(0);
+ qSIVAL(0);
+ qSIVAL(0);
+ qSIVAL(0);
+ qSIVAL(0);
+ endrpcreply(data, *rdata, q-*rdata, 0, rdata_len);
+ break;
+
+ case LSAOPENSECRET:
+ DEBUG(1,("LSAOPENSECRET\n"));
+ q = *rdata + 0x18;
+ qSIVAL(0);
+ qSIVAL(0);
+ qSIVAL(0);
+ qSIVAL(0);
+ qSIVAL(0);
+ endrpcreply(data, *rdata, q-*rdata, 0xc000034, rdata_len);
+ break;
+
+ case LSALOOKUPSIDS:
+ DEBUG(1,("LSAOPENSECRET\n"));
+ q = data + 0x18;
+ policyhandle = q; q += 20;
+ nentries = qIVAL;
+ DEBUG(4,("lookupsid entries %d\n",nentries));
+ q += (2+nentries) * 4; /* skip bufptrs */
+ /* now we have nentries sids of the form:
+ uint32 Subauthority count (SAC)
+ char Revision
+ char Subaurity count again
+ char[6] Identifier authority
+ [uint32 subauthority] * SAC
+ */
+ for (nsids = 0; nsids < nentries; nsids++)
+ {
+ DEBUG(4,("lookupsid q in %lx\n",q));
+ sids[nsids] = q;
+ DEBUG(4,("lookupsid numsubs %d\n",IVAL(q,0)));
+ q += 4+1+1+6+IVAL(q,0)*4;
+ DEBUG(4,("lookupsid q %lx\n",q));
+ }
+ /* There's 16 bytes of something after all of that, don't know
+ what it is though - incorrectly documented */
+
+ DEBUG(4,("lookupsid line %d\n",__LINE__));
+ /* formulate reply */
+ q = *rdata + 0x18;
+ qSIVAL(2); /* bufptr */
+ qSIVAL(4); /* number of referenced domains
+ - need one per each identifier authority in call */
+ qSIVAL(2); /* dom bufptr */
+ qSIVAL(32); /* max entries */
+ qSIVAL(4); /* number of reference domains? */
+
+ qunihdr(lp_workgroup()); /* reference domain */
+ qSIVAL(2); /* sid bufptr */
+
+ qunihdr("S-1-1");
+ qSIVAL(2); /* sid bufptr */
+
+ qunihdr("S-1-5");
+ qSIVAL(2); /* sid bufptr */
+
+ qunihdr("S-1-3");
+ qSIVAL(2); /* sid bufptr */
+
+ qunistr(lp_workgroup());
+ DEBUG(4,("lookupsid line %d\n",__LINE__));
+
+ strcpy(domsid,lp_domainsid());
+ p = strtok(domsid+2,"-");
+ revision = atoi(p);
+ identauth = atoi(strtok(0,"-"));
+ numsubauths = 0;
+ while (p = strtok(0, "-"))
+ subauths[numsubauths++] = atoi(p);
+ qSIVAL(numsubauths);
+ qSCVAL(revision);
+ qSCVAL(numsubauths);
+ qRSSVAL(0); /* PAXX: FIX! first 2 bytes identifier authority */
+ qRSIVAL(identauth); /* next 4 bytes */
+ DEBUG(4,("lookupsid line %d\n",__LINE__));
+ for (i = 0; i < numsubauths; i++)
+ {
+ qSIVAL(subauths[i]);
+ }
+ DEBUG(4,("lookupsid line %d\n",__LINE__));
+
+ qunistr("S-1-1");
+ qSIVAL(0); qSCVAL(1); qSCVAL(0); qRSSVAL(0); qRSIVAL(1); /* S-1-1 */
+ DEBUG(4,("lookupsid line %d\n",__LINE__));
+
+ qunistr("S-1-5");
+ qSIVAL(0); qSCVAL(1); qSCVAL(0); qRSSVAL(0); qRSIVAL(5); /* S-1-5 */
+
+ qunistr("S-1-3");
+ qSIVAL(0); qSCVAL(1); qSCVAL(0); qRSSVAL(0); qRSIVAL(3); /* S-1-3 */
+
+ qSIVAL(nentries);
+ qSIVAL(2); /* bufptr */
+ qSIVAL(nentries);
+ DEBUG(4,("lookupsid line %d\n",__LINE__));
+ for (i = 0; i < nentries; i++)
+ {
+ qSSVAL(5); /* SID name use ?! */
+ qSSVAL(0); /* undocumented */
+ DEBUG(4,("lookupsid line %d\n",__LINE__));
+ qunihdr(sidtostring(sids[i]));
+ DEBUG(4,("lookupsid sidname %s\n",sidtostring(sids[i])));
+ qSIVAL(0); /* domain index out of above reference domains */
+ }
+ DEBUG(4,("lookupsid line %d\n",__LINE__));
+ for (i = 0; i < nentries; i++)
+ {
+ qunistr(sidtostring(sids[i]));
+ }
+ qSIVAL(nentries); /* mapped count */
+ endrpcreply(data, *rdata, q-*rdata, 0, rdata_len);
+ break;
+
+ case LSALOOKUPNAMES:
+ DEBUG(1,("LSALOOKUPNAMES\n"));
+ q = data + 0x18;
+ policyhandle = q; q += 20;
+ nentries = qIVAL;
+ DEBUG(4,("lookupnames entries %d\n",nentries));
+ q += 4; /* skip second count */
+ q += 8 * nentries; /* skip pointers */
+ for (nnames = 0; nnames < nentries; nnames++)
+ {
+ names[nnames] = q; /* set name string to unicode header */
+ q += IVAL(q,0)*2; /* guessing here */
+ }
+ /* There's a translated sids structure next but it looks fals */
+
+ DEBUG(4,("lookupnames line %d\n",__LINE__));
+ /* formulate reply */
+ q = *rdata + 0x18;
+ qSIVAL(2); /* bufptr */
+ qSIVAL(4); /* number of referenced domains
+ - need one per each identifier authority in call */
+ qSIVAL(2); /* dom bufptr */
+ qSIVAL(32); /* max entries */
+ qSIVAL(4); /* number of reference domains? */
+
+ qunihdr(lp_workgroup()); /* reference domain */
+ qSIVAL(2); /* sid bufptr */
+
+ qunihdr("S-1-1");
+ qSIVAL(2); /* sid bufptr */
+
+ qunihdr("S-1-5");
+ qSIVAL(2); /* sid bufptr */
+
+ qunihdr("S-1-3");
+ qSIVAL(2); /* sid bufptr */
+
+ qunistr(lp_workgroup());
+ DEBUG(4,("lookupnames line %d\n",__LINE__));
+
+ strcpy(domsid,lp_domainsid());
+ p = strtok(domsid+2,"-");
+ revision = atoi(p);
+ identauth = atoi(strtok(0,"-"));
+ numsubauths = 0;
+ while (p = strtok(0, "-"))
+ subauths[numsubauths++] = atoi(p);
+ qSIVAL(numsubauths);
+ qSCVAL(revision);
+ qSCVAL(numsubauths);
+ qRSSVAL(0); /* PAXX: FIX! first 2 bytes identifier authority */
+ qRSIVAL(identauth); /* next 4 bytes */
+ DEBUG(4,("lookupsid line %d\n",__LINE__));
+ for (i = 0; i < numsubauths; i++)
+ {
+ qSIVAL(subauths[i]);
+ }
+ DEBUG(4,("lookupsid line %d\n",__LINE__));
+
+ qunistr("S-1-1");
+ qSIVAL(0); qSCVAL(1); qSCVAL(0); qRSSVAL(0); qRSIVAL(1); /* S-1-1 */
+ DEBUG(4,("lookupsid line %d\n",__LINE__));
+
+ qunistr("S-1-5");
+ qSIVAL(0); qSCVAL(1); qSCVAL(0); qRSSVAL(0); qRSIVAL(5); /* S-1-5 */
+
+ qunistr("S-1-3");
+ qSIVAL(0); qSCVAL(1); qSCVAL(0); qRSSVAL(0); qRSIVAL(3); /* S-1-3 */
+
+ qSIVAL(nentries);
+ qSIVAL(2); /* bufptr */
+ qSIVAL(nentries);
+ DEBUG(4,("lookupnames line %d\n",__LINE__));
+ for (i = 0; i < nentries; i++)
+ {
+ qSSVAL(5); /* SID name use 5 == well known sid, 1 == user sid see showacls */
+ qSSVAL(5); /* undocumented */
+ DEBUG(4,("lookupnames line %d\n",__LINE__));
+ qSIVAL(nametorid(names[i]));
+ DEBUG(4,("lookupnames nametorid %d\n",nametorid(names[i])));
+ qSIVAL(0); /* domain index out of above reference domains */
+ }
+ qSIVAL(nentries); /* mapped count */
+ endrpcreply(data, *rdata, q-*rdata, 0, rdata_len);
+ break;
+
+ default:
+ DEBUG(4, ("NTLSARPC, unknown code: %lx\n", opnum));
+ }
+ return(True);
+}
+
+BOOL api_netlogrpcTNP(int cnum,int uid, char *param,char *data,
+ int mdrcnt,int mprcnt,
+ char **rdata,char **rparam,
+ int *rdata_len,int *rparam_len)
+{
+ uint16 opnum;
+ char *q;
+ char *domainname;
+ int domlen;
+ pstring domsid;
+ char *p;
+ int numsubauths;
+ int subauths[MAXSUBAUTHS];
+ struct smb_passwd *smb_pass; /* To check if machine account exists */
+ pstring machacct;
+ pstring foo;
+ uint16 infoclass;
+ uint16 revision; /* Domain sid revision */
+ int identauth;
+ int i;
+ char *logonsrv;
+ char *unicomp;
+ char *accountname;
+ uint16 secchanneltype;
+ uint32 negflags;
+ char netcred[8];
+ uint32 rcvcred[8];
+ char rtncred[8];
+ uint32 clnttime;
+ uint32 rtntime;
+ char *newpass;
+ uint16 logonlevel;
+ uint16 switchval;
+ uint16 dommaxlen;
+ uint16 paramcontrol;
+ uint32 logonid[2];
+ uint16 usernamelen;
+ uint16 usernamemaxlen;
+ uint16 wslen;
+ uint16 wsmaxlen;
+ uchar *rc4lmowfpass;
+ uchar *rc4ntowfpass;
+ char *domain;
+ char *username;
+ char *ws;
+ struct uinfo *userinfo;
+ int pkttype;
+ ArcfourContext c;
+ uchar rc4key[16];
+ uchar ntowfpass[16];
+
+ opnum = SVAL(data,22);
+
+ pkttype = CVAL(data, 2);
+ if (pkttype == 0x0b) /* RPC BIND */
+ {
+ DEBUG(4,("netlogon rpc bind %x\n",pkttype));
+ LsarpcTNP1(data,rdata,rdata_len);
+ return True;
+ }
+
+ DEBUG(4,("netlogon TransactNamedPipe op %x\n",opnum));
+ initrpcreply(data, *rdata);
+ DEBUG(4,("netlogon LINE %d\n",__LINE__));
+ switch (opnum)
+ {
+ case LSAREQCHAL:
+ DEBUG(1,("LSAREQCHAL\n"));
+ q = data + 0x18;
+ dump_data(1,q,128);
+ logonsrv = q + 16; /* first 16 bytes, buffer ptr, + unicode lenghts */
+ q = skip_unicode_string(logonsrv,1) + 12;
+ q = align4(q, data);
+ unicomp = q;
+ q = skip_unicode_string(unicomp,1);
+
+
+ DEBUG(1,("logonsrv=%s unicomp=%s\n",
+ unistr(logonsrv),
+ unistr(unicomp)));
+
+ dcauth[cnum].chal[0] = IVAL(q, 0);
+ dcauth[cnum].chal[1] = IVAL(q, 4);
+ dcauth[cnum].cred[0] = IVAL(q, 0); /* this looks weird (tridge) */
+ dcauth[cnum].cred[1] = IVAL(q, 4);
+
+DEBUG(1,("NL: client challenge %08x %08x\n", dcauth[cnum].chal[0],dcauth[cnum].chal[1]));
+
+ /* PAXX: set these to random values */
+ dcauth[cnum].svrchal[0] = 0x11111111;
+ dcauth[cnum].svrchal[1] = 0x22222222;
+ dcauth[cnum].svrcred[0] = 0x11111111;
+ dcauth[cnum].svrcred[1] = 0x22222222;
+ strcpy(machacct,unistr(unicomp));
+ strcat(machacct, "$");
+ smb_pass = get_smbpwnam(machacct);
+ if(smb_pass)
+ memcpy(dcauth[cnum].md4pw, smb_pass->smb_nt_passwd, 16);
+ else
+ {
+ /* No such machine account. Should error out here, but we'll
+ print and carry on */
+ DEBUG(1,("No account in domain at REQCHAL for %s\n", machacct));
+ }
+ for(i=0;i<16;i++) sprintf(foo+i*2,"%02x",dcauth[cnum].md4pw[i]);
+ DEBUG(1,("pass %s %s\n", machacct, foo));
+ setsesskey(cnum);
+ q = *rdata + 0x18;
+ qSIVAL(dcauth[cnum].svrchal[0]);
+ qSIVAL(dcauth[cnum].svrchal[1]);
+
+DEBUG(1,("NL: server challenge %08x %08x\n",
+ dcauth[cnum].svrchal[0],dcauth[cnum].svrchal[1]));
+
+ endrpcreply(data, *rdata, q-*rdata, 0, rdata_len);
+ break;
+
+ case LSAAUTH2:
+ DEBUG(1,("LSAAUTH2\n"));
+ dump_data(1,q,128);
+ q = data + 0x18;
+ logonsrv = q + 16;
+ q = skip_unicode_string(logonsrv,1)+12;
+ q = align4(q, data);
+ accountname = q;
+
+ q = skip_unicode_string(accountname,1);
+ secchanneltype = qSVAL;
+ q += 12;
+ q = align4(q, data);
+ unicomp = q;
+ dump_data(1,unicomp,32);
+ q = skip_unicode_string(unicomp,1);
+ rcvcred[0] = qIVAL;
+ rcvcred[1] = qIVAL;
+ q = align4(q, data);
+ negflags = qIVAL;
+ DEBUG(3,("AUTH2 logonsrv=%s accountname=%s unicomp=%s %lx %lx %lx\n",
+ unistr(logonsrv), unistr(accountname), unistr(unicomp),
+ rcvcred[0], rcvcred[1], negflags));
+
+DEBUG(1,("NL: recvcred %08x %08x negflags=%08x\n",
+ rcvcred[0], rcvcred[1], negflags));
+
+ checkcred(cnum, rcvcred[0], rcvcred[1], 0);
+ q = *rdata + 0x18;
+ makecred(cnum, 0, q);
+ q += 8;
+
+ qSIVAL(negflags);
+ /* update stored client credentials */
+ dcauth[cnum].cred[0] = dcauth[cnum].svrcred[0] = rcvcred[0];
+ dcauth[cnum].cred[1] = dcauth[cnum].svrcred[1] = rcvcred[1];
+ endrpcreply(data, *rdata, q-*rdata, 0, rdata_len);
+ break;
+
+ case LSASVRPWSET:
+ DEBUG(1,("LSASVRPWSET\n"));
+ q = data + 0x18;
+ dump_data(1,q,128);
+ logonsrv = q + 16;
+ q = skip_unicode_string(logonsrv,1)+12;
+ q = align4(q, data);
+ accountname = q;
+ q = skip_unicode_string(accountname,1);
+ secchanneltype = qSVAL;
+ q += 12;
+ q = align4(q, data);
+ unicomp = q;
+ q = skip_unicode_string(unicomp,1);
+ rcvcred[0] = qIVAL;
+ rcvcred[1] = qIVAL;
+ clnttime = qIVAL;
+
+ DEBUG(1,("PWSET logonsrv=%s accountname=%s unicomp=%s\n",
+ unistr(logonsrv), unistr(accountname), unistr(unicomp)));
+
+ checkcred(cnum, rcvcred[0], rcvcred[1], clnttime);
+ DEBUG(3,("PWSET %lx %lx %lx %lx\n", rcvcred[0], rcvcred[1], clnttime, negflags));
+ newpass = q;
+
+ DEBUG(1,("PWSET logonsrv=%s accountname=%s unicomp=%s newpass=%s\n",
+ unistr(logonsrv), unistr(accountname), unistr(unicomp), newpass));
+
+ /* PAXX: For the moment we'll reject these */
+ /* TODO Need to set newpass in smbpasswd file for accountname */
+ q = *rdata + 0x18;
+ makecred(cnum, clnttime+1, q);
+ q += 8;
+ qSIVAL(0); /* timestamp. Seems to be ignored */
+
+ dcauth[cnum].svrcred[0] = dcauth[cnum].cred[0] = dcauth[cnum].cred[0] + clnttime + 1;
+
+ endrpcreply(data, *rdata, q-*rdata, 0xc000006a, rdata_len);
+ break;
+
+ case LSASAMLOGON:
+ DEBUG(1,("LSASAMLOGON\n"));
+ dump_data(1,data,128);
+ q = data + 0x18;
+ logonsrv = q + 16;
+ DEBUG(1,("SMLOG %d\n", __LINE__));
+ q = skip_unicode_string(logonsrv,1)+16;
+ q = align4(q, data);
+ unicomp = q;
+ q = skip_unicode_string(unicomp,1)+4;
+ DEBUG(1,("SMLOG %d logonsrv=%s unicomp=%s\n",
+ __LINE__, unistr(logonsrv), unistr(unicomp)));
+ q = align4(q, data);
+ rcvcred[0] = qIVAL;
+ DEBUG(1,("SMLOG %d\n", __LINE__));
+ rcvcred[1] = qIVAL;
+ DEBUG(1,("SMLOG %d\n", __LINE__));
+ clnttime = qIVAL;
+ checkcred(cnum, rcvcred[0], rcvcred[1], clnttime);
+ q += 2;
+ rtncred[0] = qIVAL; /* all these are ignored */
+ DEBUG(1,("SMLOG %d\n", __LINE__));
+ rtncred[1] = qIVAL;
+ rtntime = qIVAL;
+ logonlevel = qSVAL;
+ DEBUG(1,("SMLOG %d\n", __LINE__));
+ switchval = qSVAL;
+ switch (switchval)
+ {
+ case 1:
+
+ q += 6;
+ domlen = qSVAL;
+ dommaxlen = qSVAL; q += 4;
+ paramcontrol = qIVAL;
+ logonid[0] = qIVAL; /* low part */
+ logonid[1] = qIVAL; /* high part */
+
+ usernamelen = qSVAL;
+
+ DEBUG(1,("SMLOG %d\n", __LINE__));
+ usernamemaxlen = qSVAL; q += 4;
+
+ DEBUG(1,("usernamelen=%d maxlen=%d dommaxlen=%d\n",
+ usernamelen, usernamemaxlen, dommaxlen));
+
+ dump_data(1,q,128);
+
+ wslen = qSVAL;
+ wsmaxlen = qSVAL; q += 4;
+ rc4lmowfpass = q; q += 16;
+ rc4ntowfpass = q; q += 16;
+
+ q += 12; domain = q; q += dommaxlen + 12;
+ q = align4(q, data);
+ username = q; q += usernamemaxlen + 12;
+ q = align4(q, data);
+ ws = q;
+ DEBUG(1,("domain=%s username=%s ws=%s\n",
+ unistr(domain), unistr(username),
+ unistr(ws)));
+ break;
+ default:
+ DEBUG(0,("unknown switch in SAMLOGON %d\n",
+ switchval));
+ }
+ for(i=0;i<16;i++) sprintf(foo+i*2,"%02x",username[i]);
+ DEBUG(1,("userNAME %s [%s]\n", foo, username));
+ DEBUG(1,("SMLOG %d\n", __LINE__));
+ q = *rdata + 0x18;
+ qSIVAL(0x16a4b4); /* magic buffer pointer ? */
+ makecred(cnum, clnttime+1, q);
+ dcauth[cnum].svrcred[0] = dcauth[cnum].cred[0] = dcauth[cnum].cred[0] + clnttime + 1;
+ q += 8;
+ qSIVAL(0); /* timestamp. client doesn't care */
+ qSSVAL(3); /* switch value 3. May be others? */
+ qSSVAL(0); /* undocumented */
+ DEBUG(1,("SMLOG %d\n", __LINE__));
+
+ memset(rc4key, 0, sizeof rc4key);
+ SIVAL(rc4key, 0, dcauth[cnum].sesskey[0]);
+ SIVAL(rc4key, 4, dcauth[cnum].sesskey[1]);
+ for(i=0;i<16;i++) sprintf(foo+i*2,"%02x",rc4ntowfpass[i]);
+ DEBUG(1,("rc4ntowf %s\n", foo));
+ arcfour_init(&c, rc4key, sizeof rc4key);
+ arcfour_encrypt(&c, ntowfpass, rc4ntowfpass, sizeof ntowfpass);
+ for(i=0;i<16;i++) sprintf(foo+i*2,"%02x",ntowfpass[i]);
+ DEBUG(1,("ntowf %s\n", foo));
+
+ if(!(userinfo = getuserinfo(username, usernamelen, ntowfpass))) {
+ qSIVAL(0); /* no buffer */
+ qSCVAL(1); /* Authoratitive. Change if passthrough? */
+ qSCVAL(0); /* pad for above boolean */
+ qSSVAL(0); /* pad for above boolean */
+
+ endrpcreply(data, *rdata, q-*rdata, 0xc0000064, rdata_len);
+ break;
+ }
+
+ qSIVAL(2); /* another magic bufptr? */
+ DEBUG(1,("SMLOG %d %lx\n", __LINE__, userinfo));
+ qSIVAL(userinfo->logontime[0]); qSIVAL(userinfo->logontime[1]);
+ qSIVAL(userinfo->logofftime[0]); qSIVAL(userinfo->logofftime[1]);
+ DEBUG(1,("SMLOG %d %lx\n", __LINE__, userinfo->passlastsettime[1]));
+ qSIVAL(userinfo->kickofftime[0]); qSIVAL(userinfo->kickofftime[1]);
+ qSIVAL(userinfo->passlastsettime[0]); qSIVAL(userinfo->passlastsettime[1]);
+ qSIVAL(userinfo->passcanchgtime[0]); qSIVAL(userinfo->passcanchgtime[1]);
+ qSIVAL(userinfo->passmustchgtime[0]); qSIVAL(userinfo->passmustchgtime[1]);
+ DEBUG(1,("SMLOG %d %s\n", __LINE__, userinfo->effectivename));
+ qunihdr(userinfo->effectivename);
+ qunihdr(userinfo->fullname);
+ DEBUG(1,("SMLOG %d\n", __LINE__));
+ qunihdr(userinfo->logonscript);
+ qunihdr(userinfo->profilepath);
+ qunihdr(userinfo->homedirectory);
+ qunihdr(userinfo->homedirectorydrive);
+ DEBUG(1,("SMLOG %d\n", __LINE__));
+ qSSVAL(userinfo->logoncount);
+ qSSVAL(userinfo->badpwcount);
+ qSIVAL(userinfo->uid);
+ qSIVAL(userinfo->gid);
+ DEBUG(1,("SMLOG %d\n", __LINE__));
+ qSIVAL(userinfo->ngroups);
+ qSIVAL(8); /* ptr to groups */
+ qSIVAL(userinfo->userflags);
+ DEBUG(1,("SMLOG %d\n", __LINE__));
+ qSIVAL(0); qSIVAL(0); qSIVAL(0); qSIVAL(0); /* unused user session key */
+ qunihdr(userinfo->logonserver);
+ qunihdr(userinfo->logondomain);
+ DEBUG(1,("SMLOG %d\n", __LINE__));
+ qSIVAL(2); /* logon domain id ptr */
+ DEBUG(1,("SMLOG %d\n", __LINE__));
+ memset(q,0,40); q += 40; /* expansion room */
+ DEBUG(1,("SMLOG %d\n", __LINE__));
+ qSIVAL(userinfo->nsids);
+ DEBUG(1,("SMLOG %d\n", __LINE__));
+ qSIVAL(0); /* ptr to sids and values */
+ DEBUG(1,("SMLOG %d\n", __LINE__));
+ qunistr(userinfo->effectivename);
+ DEBUG(1,("SMLOG %d\n", __LINE__));
+ qunistr(userinfo->fullname);
+ DEBUG(1,("SMLOG %d\n", __LINE__));
+ qunistr(userinfo->logonscript);
+ DEBUG(1,("SMLOG %d\n", __LINE__));
+ qunistr(userinfo->profilepath);
+ qunistr(userinfo->homedirectory);
+ qunistr(userinfo->homedirectorydrive);
+ DEBUG(1,("SMLOG %d\n", __LINE__));
+ qSIVAL(userinfo->ngroups);
+ for (i = 0; i < userinfo->ngroups; i++)
+ {
+ qSIVAL(userinfo->groups[i].gid);
+ qSIVAL(userinfo->groups[i].attr);
+ }
+ qunistr(userinfo->logonserver);
+ qunistr(userinfo->logondomain);
+ for (i = 0; i < userinfo->nsids; i++)
+ {
+ /* put the extra sids: PAXX: TODO */
+ }
+ /* Assumption. This is the only domain, sending our SID */
+ /* PAXX: may want to do passthrough later */
+ strcpy(domsid,lp_domainsid());
+ DEBUG(4,("netlogon LINE %d %lx %s\n",__LINE__, q, domsid));
+ /* assume, but should check, that domsid starts "S-" */
+ p = strtok(domsid+2,"-");
+ revision = atoi(p);
+ DEBUG(4,("netlogon LINE %d %lx %s rev %d\n",__LINE__, q, p, revision));
+ identauth = atoi(strtok(0,"-"));
+ DEBUG(4,("netlogon LINE %d %lx %s ia %d\n",__LINE__, q, p, identauth));
+ numsubauths = 0;
+ while (p = strtok(0, "-"))
+ subauths[numsubauths++] = atoi(p);
+ qSIVAL(numsubauths);
+ qSCVAL(revision);
+ qSCVAL(numsubauths);
+ qRSSVAL(0); /* PAXX: FIX. first 2 bytes identifier authority */
+ qRSIVAL(identauth); /* next 4 bytes */
+ DEBUG(1,("SMLOG %d\n", __LINE__));
+ for (i = 0; i < numsubauths; i++)
+ {
+ qSIVAL(subauths[i]);
+ }
+ qSCVAL(1); /* Authoratitive. Change if passthrough? */
+ qSCVAL(0); /* pad for above boolean */
+ qSSVAL(0); /* pad for above boolean */
+
+ endrpcreply(data, *rdata, q-*rdata, 0, rdata_len);
+ break;
+
+ case LSASAMLOGOFF:
+ DEBUG(1,("LSASAMLOGOFF\n"));
+ q = data + 0x18;
+ logonsrv = q + 16;
+ DEBUG(1,("SAMLOGOFF %d\n", __LINE__));
+ unicomp = skip_unicode_string(logonsrv,1)+16;
+ if (strlen(unistr(logonsrv)) % 2 == 0)
+ q += 2;
+ DEBUG(1,("SMLOG %d\n", __LINE__));
+ q = skip_unicode_string(unicomp,1)+4;
+ if (strlen(unistr(unicomp)) % 2 == 0)
+ q += 2;
+ DEBUG(1,("SMLOG %d\n", __LINE__));
+ rcvcred[0] = qIVAL;
+ DEBUG(1,("SMLOG %d\n", __LINE__));
+ rcvcred[1] = qIVAL;
+ DEBUG(1,("SMLOG %d\n", __LINE__));
+ clnttime = qIVAL;
+ checkcred(cnum, rcvcred[0], rcvcred[1], clnttime);
+ q += 4;
+ rtncred[0] = qIVAL; /* all these are ignored */
+ DEBUG(1,("SMLOG %d\n", __LINE__));
+ rtncred[1] = qIVAL;
+ rtntime = qIVAL;
+ logonlevel = qSVAL;
+ DEBUG(1,("SMLOG %d\n", __LINE__));
+ switchval = qSVAL;
+ switch (switchval)
+ {
+ case 1:
+ q += 4;
+ domlen = qSVAL;
+ dommaxlen = qSVAL; q += 4;
+ paramcontrol = qIVAL;
+ logonid[0] = qIVAL; /* low part */
+ logonid[1] = qIVAL; /* high part */
+ usernamelen = qSVAL;
+ DEBUG(1,("SMLOG %d\n", __LINE__));
+ usernamemaxlen = qSVAL; q += 4;
+ wslen = qSVAL;
+ wsmaxlen = qSVAL; q += 4;
+ rc4lmowfpass = q; q += 16;
+ rc4ntowfpass = q; q += 16;
+ q += 12; domain = q; q += dommaxlen + 12;
+ if ((domlen/2) % 2 != 0) q += 2;
+ username = q; q += usernamemaxlen + 12; /* PAXX: HACK */
+ if ((usernamelen/2) % 2 != 0) q += 2;
+ ws = q;
+ break;
+ default: DEBUG(0, ("unknown switch in SAMLOGON %d\n",switchval));
+ }
+ DEBUG(1,("SAMLOGOFF %s\n", unistr(username)));
+ default:
+ DEBUG(4, ("**** netlogon, unknown code: %lx\n", opnum));
+ }
+ return(True);
+}
+
+void initrpcreply(char *inbuf, char *q)
+{
+ uint32 callid;
+
+ qSCVAL(5); /* RPC version 5 */
+ qSCVAL(0); /* minor version 0 */
+ qSCVAL(2); /* RPC response packet */
+ qSCVAL(3); /* first frag + last frag */
+ qRSIVAL(0x10000000); /* packed data representation */
+ qRSSVAL(0); /* fragment length, fill in later */
+ qSSVAL(0); /* authentication length */
+ callid = RIVAL(inbuf,12);
+ qRSIVAL(callid); /* call identifier - match incoming RPC */
+ qSIVAL(0x18); /* allocation hint (no idea) */
+ qSSVAL(0); /* presentation context identifier */
+ qSCVAL(0); /* cancel count */
+ qSCVAL(0); /* reserved */
+}
+
+endrpcreply(char *inbuf, char *q, int datalen, int rtnval, int *rlen)
+{
+ SSVAL(q, 8, datalen + 4);
+ SIVAL(q,0x10,datalen+4-0x18); /* allocation hint */
+ SIVAL(q, datalen, rtnval);
+ *rlen = datalen + 4;
+ {int fd; fd = open("/tmp/rpc", O_RDWR);write(fd,q,datalen+4);}
+}
+
+void setsesskey(int cnum)
+{
+ uint32 sum[2];
+ char netsum[8];
+ char netsesskey[8];
+ char icv[8];
+
+ sum[0] = dcauth[cnum].chal[0] + dcauth[cnum].svrchal[0];
+ sum[1] = dcauth[cnum].chal[1] + dcauth[cnum].svrchal[1];
+ SIVAL(netsum,0,sum[0]);
+ SIVAL(netsum,4,sum[1]);
+ E1(dcauth[cnum].md4pw,netsum,icv);
+ E1(dcauth[cnum].md4pw+9,icv,netsesskey);
+ dcauth[cnum].sesskey[0] = IVAL(netsesskey,0);
+ dcauth[cnum].sesskey[1] = IVAL(netsesskey,4);
+
+DEBUG(1,("NL: session key %08x %08x\n",
+ dcauth[cnum].sesskey[0],
+ dcauth[cnum].sesskey[1]));
+}
+
+void checkcred(int cnum, uint32 cred0, uint32 cred1, uint32 time)
+{
+ uint32 sum[2];
+ char netdata[8];
+ char netsesskey[8];
+ char calccred[8];
+ char icv[8];
+ char key2[7];
+
+ SIVAL(netdata, 0, dcauth[cnum].cred[0]+time);
+ SIVAL(netdata, 4, dcauth[cnum].cred[1]);
+ SIVAL(netsesskey, 0, dcauth[cnum].sesskey[0]);
+ SIVAL(netsesskey, 4, dcauth[cnum].sesskey[1]);
+ E1(netsesskey,netdata,icv);
+ memset(key2, 0, sizeof key2);
+ key2[0] = netsesskey[7];
+ E1(key2, icv, calccred);
+ if (IVAL(calccred,0) != cred0 ||
+ IVAL(calccred,4) != cred1)
+ {
+ DEBUG(1,("Incorrect client credential received cred %lx %lx time %lx sk %lx %lx cred %lx %lx expcred %lx %lx\n",
+ cred0, cred1, time,
+ dcauth[cnum].sesskey[0], dcauth[cnum].sesskey[1],
+ dcauth[cnum].cred[0], dcauth[cnum].cred[1],
+ IVAL(calccred,0), IVAL(calccred,4)));
+ /* PAXX: do something about it! */
+ } else
+ DEBUG(4,("Correct client credential received chal %lx %lx time %lx sk %lx %lx cred %lx %lx expcred %lx %lx\n",
+ cred0, cred1, time,
+ dcauth[cnum].sesskey[0], dcauth[cnum].sesskey[1],
+ dcauth[cnum].cred[0], dcauth[cnum].cred[1],
+ IVAL(calccred,0), IVAL(calccred,4)));
+}
+
+void makecred(int cnum, uint32 time, char *calccred)
+{
+ uint32 sum[2];
+ char netdata[8];
+ char netsesskey[8];
+ char icv[8];
+ char key2[7];
+
+ SIVAL(netdata, 0, dcauth[cnum].svrcred[0]+time);
+ SIVAL(netdata, 4, dcauth[cnum].svrcred[1]);
+ SIVAL(netsesskey, 0, dcauth[cnum].sesskey[0]);
+ SIVAL(netsesskey, 4, dcauth[cnum].sesskey[1]);
+ E1(netsesskey,netdata,icv);
+ memset(key2, 0, sizeof key2);
+ key2[0] = netsesskey[7];
+ E1(key2, icv, calccred);
+ DEBUG(4,("Server credential: chal %lx %lx sk %lx %lx cred %lx %lx calc %lx %lx\n",
+ dcauth[cnum].svrchal[0], dcauth[cnum].svrchal[1],
+ dcauth[cnum].sesskey[0], dcauth[cnum].sesskey[1],
+ dcauth[cnum].svrcred[0], dcauth[cnum].svrcred[1],
+ IVAL(calccred, 0), IVAL(calccred, 4)));
+}
+
+
+struct uinfo *getuserinfo(char *user, int len, char *ntowfpass)
+{
+ static struct uinfo u;
+ static pstring fullnm;
+ static pstring ascuser;
+ extern pstring myname;
+ static pstring stme;
+ static pstring stdom;
+ struct smb_passwd *smb_pass;
+
+ strcpy(ascuser,unistr(user));
+ ascuser[len/2] = 0; /* PAXX: FIXMEFIXMEFIXME */
+ DEBUG(1,("GETUSER username :%s: len=%d\n",ascuser, len));
+
+ smb_pass = get_smbpwnam(ascuser);
+ if(!smb_pass)
+ return 0;
+ DEBUG(1,("GETU %d\n", __LINE__));
+ if (memcmp(ntowfpass, smb_pass->smb_nt_passwd, 16)) {
+ DEBUG(1,("pass mismatch:\n"));
+ dump_data(1,ntowfpass,16);
+ dump_data(1,smb_pass->smb_nt_passwd,16);
+ return 0;
+ }
+
+ DEBUG(1,("GETU %d\n", __LINE__));
+ u.logontime[0] = 0xffffffff; u.logontime[1] = 0x7fffffff;
+ u.logofftime[0] = 0xffffffff; u.logofftime[1] = 0x7fffffff;
+ u.kickofftime[0] = 0xffffffff; u.kickofftime[1] = 0x7fffffff;
+ DEBUG(1,("GETU %d\n", __LINE__));
+ u.passlastsettime[0] = 0xffffffff; u.passlastsettime[1] = 0x7fffffff;
+ u.passcanchgtime[0] = 0xffffffff; u.passcanchgtime[1] = 0x7fffffff;
+ u.passmustchgtime[0] = 0xffffffff; u.passmustchgtime[1] = 0x7fffffff;
+ DEBUG(1,("GETU %d\n", __LINE__));
+ u.effectivename = ascuser;
+ strcpy(fullnm, "Full name of ");
+ strcat(fullnm, ascuser);
+ DEBUG(1,("GETU %d\n", __LINE__));
+ u.fullname = fullnm;
+ u.logonscript = "foologin.cmd";
+ u.profilepath = "prof";
+ u.homedirectory = "foohomes";
+ DEBUG(1,("GETU %d\n", __LINE__));
+ u.homedirectorydrive = "a:";
+ u.logoncount = 7;
+ u.badpwcount = 8;
+ u.uid = 778;
+ DEBUG(1,("GETU %d\n", __LINE__));
+ u.gid = 998;
+ u.ngroups = 2;
+ u.groups = (struct groupinfo *)(malloc(sizeof (struct groupinfo) * 2));
+ u.groups[0].gid = 776;
+ DEBUG(1,("GETU %d\n", __LINE__));
+ u.groups[0].attr = 0x7;
+ u.groups[1].gid = 776;
+ u.groups[1].attr = 0x7;
+ u.userflags = 0x20;
+ u.logonserver = stme;
+ get_myname(myname,NULL);
+ strcpy(stme, myname);
+ strupper(stme);
+ DEBUG(1,("LS %s\n", u.logonserver));
+ u.logondomain = stdom;
+ strcpy(stdom, lp_workgroup());
+ strupper(stdom);
+ DEBUG(1,("DOM %s\n", u.logondomain));
+ u.nsids = 0;
+ u.sids = 0;
+ DEBUG(1,("GETU %d\n", __LINE__));
+ return &u;
+};
+
+int
+nametorid(char *uniuser)
+{
+ if (!strncmp(unistr(uniuser+12),"ashtonp",7))
+ return 2000;
+ if (!strncmp(unistr(uniuser+12),"user1",5))
+ return 1;
+ if (!strncmp(unistr(uniuser+12),"user2",5))
+ return 10;
+ if (!strncmp(unistr(uniuser+12),"user3",5))
+ return 100;
+ return 3000;
+}
+
+#endif /* NTDOMAIN */
--
cgit
From b8ff5543b9fa45095caa9f24aeb22a1dcc1cd308 Mon Sep 17 00:00:00 2001
From: Jeremy Allison
Date: Wed, 8 Oct 1997 20:34:13 +0000
Subject: Makefile: Split definitions for SGI4,5,6. includes.h: Split
definitions for SGI4,5,6. pipes.c: Moved Luke's #ifdef to remove warnings.
quotas.c: Two changes for FreeBSD and SGI. server.c: Quota changes for large
filesystems. Jeremy (jallison@whistle.com)
---
source/include/includes.h | 4 +-
source/smbd/pipes.c | 2 +-
source/smbd/quotas.c | 147 +++++++++++++++++++++++++++++++++++++++++++++-
source/smbd/server.c | 20 ++++++-
4 files changed, 167 insertions(+), 6 deletions(-)
diff --git a/source/include/includes.h b/source/include/includes.h
index d1afc34de92..4ca1d4c3b0d 100644
--- a/source/include/includes.h
+++ b/source/include/includes.h
@@ -340,7 +340,7 @@ char *getwd(char *);
#define USE_WAITPID
#endif
-#ifdef SGI
+#ifdef SGI4
#include
#include
#include
@@ -355,7 +355,7 @@ char *getwd(char *);
#define USE_SETSID
#endif
-#ifdef SGI5
+#if defined(SGI5) || defined(SGI6)
#include
#include
#include
diff --git a/source/smbd/pipes.c b/source/smbd/pipes.c
index 88cf0b2d713..870dc16fddf 100644
--- a/source/smbd/pipes.c
+++ b/source/smbd/pipes.c
@@ -364,6 +364,7 @@ BOOL api_LsarpcTNP(int cnum,int uid, char *param,char *data,
return(True);
}
+#ifdef UNDEFINED_NTDOMAIN
/*
PAXX: Someone fix above.
The above API is indexing RPC calls based on RPC flags and
@@ -953,7 +954,6 @@ static void api_lsa_lookup_sids( char *param, char *data,
}
-#ifdef UNDEFINED_NTDOMAIN
/*
PAXX: Someone fix above.
The above API is indexing RPC calls based on RPC flags and
diff --git a/source/smbd/quotas.c b/source/smbd/quotas.c
index d4f746c9e36..8810bcd909d 100644
--- a/source/smbd/quotas.c
+++ b/source/smbd/quotas.c
@@ -416,10 +416,132 @@ BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
}
return (True);
}
+
+#elif defined (SGI6)
+/****************************************************************************
+try to get the disk space from disk quotas (IRIX 6.2 version)
+****************************************************************************/
+
+#include
+#include
+
+BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
+{
+ uid_t euser_id;
+ int r;
+ struct dqblk D;
+ struct fs_disk_quota F;
+ struct stat S;
+ FILE *fp;
+ struct mntent *mnt;
+ int devno;
+ int found;
+
+ /* find the block device file */
+
+ if ( stat(path, &S) == -1 ) {
+ return(False) ;
+ }
+
+ devno = S.st_dev ;
+
+ fp = setmntent(MOUNTED,"r");
+ found = False ;
+
+ while ((mnt = getmntent(fp))) {
+ if ( stat(mnt->mnt_dir,&S) == -1 )
+ continue ;
+ if (S.st_dev == devno) {
+ found = True ;
+ break ;
+ }
+ }
+ endmntent(fp) ;
+
+ if (!found) {
+ return(False);
+ }
+
+ euser_id=geteuid();
+ seteuid(0);
+
+ /* Use softlimit to determine disk space, except when it has been exceeded */
+
+ *bsize = 512;
+
+ if ( 0 == strcmp ( mnt->mnt_type, "efs" ))
+ {
+ r=quotactl (Q_GETQUOTA, mnt->mnt_fsname, euser_id, (caddr_t) &D);
+
+ if (r==-1)
+ return(False);
+
+ /* Use softlimit to determine disk space, except when it has been exceeded */
+ if (
+ (D.dqb_bsoftlimit && D.dqb_curblocks>=D.dqb_bsoftlimit) ||
+ (D.dqb_bhardlimit && D.dqb_curblocks>=D.dqb_bhardlimit) ||
+ (D.dqb_fsoftlimit && D.dqb_curfiles>=D.dqb_fsoftlimit) ||
+ (D.dqb_fhardlimit && D.dqb_curfiles>=D.dqb_fhardlimit)
+ )
+ {
+ *dfree = 0;
+ *dsize = D.dqb_curblocks;
+ }
+ else if (D.dqb_bsoftlimit==0 && D.dqb_bhardlimit==0)
+ {
+ return(False);
+ }
+ else
+ {
+ *dfree = D.dqb_bsoftlimit - D.dqb_curblocks;
+ *dsize = D.dqb_bsoftlimit;
+ }
+
+ }
+ else if ( 0 == strcmp ( mnt->mnt_type, "xfs" ))
+ {
+ r=quotactl (Q_XGETQUOTA, mnt->mnt_fsname, euser_id, (caddr_t) &F);
+
+ if (r==-1)
+ return(False);
+
+ /* Use softlimit to determine disk space, except when it has been exceeded */
+ if (
+ (F.d_blk_softlimit && F.d_bcount>=F.d_blk_softlimit) ||
+ (F.d_blk_hardlimit && F.d_bcount>=F.d_blk_hardlimit) ||
+ (F.d_ino_softlimit && F.d_icount>=F.d_ino_softlimit) ||
+ (F.d_ino_hardlimit && F.d_icount>=F.d_ino_hardlimit)
+ )
+ {
+ /*
+ * Fixme!: these are __uint64_t, this may truncate values
+ */
+ *dfree = 0;
+ *dsize = (int) F.d_bcount;
+ }
+ else if (F.d_blk_softlimit==0 && F.d_blk_hardlimit==0)
+ {
+ return(False);
+ }
+ else
+ {
+ *dfree = (int)(F.d_blk_softlimit - F.d_bcount);
+ *dsize = (int)F.d_blk_softlimit;
+ }
+
+ }
+ else
+ return(False);
+
+ return (True);
+
+}
+
#else
#ifdef __FreeBSD__
#include
+#include
#elif AIX
/* AIX quota patch from Ole Holm Nielsen */
#include
@@ -463,7 +585,25 @@ BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
}
#else /* USE_SETRES */
#if defined(__FreeBSD__)
- r= quotactl(path,Q_GETQUOTA,euser_id,(char *) &D);
+ {
+ /* FreeBSD patches from Marty Moll */
+ uid_t user_id;
+ gid_t egrp_id;
+
+ /* Need to be root to get quotas in FreeBSD */
+ user_id = getuid();
+ egrp_id = getegid();
+ setuid(0);
+ seteuid(0);
+ r= quotactl(path,QCMD(Q_GETQUOTA,USRQUOTA),euser_id,(char *) &D);
+
+ /* As FreeBSD has group quotas, if getting the user
+ quota fails, try getting the group instead. */
+ if (r)
+ r= quotactl(path,QCMD(Q_GETQUOTA,GRPQUOTA),egrp_id,(char *) &D);
+ setuid(user_id);
+ seteuid(euser_id);
+ }
#elif defined(AIX)
/* AIX has both USER and GROUP quotas:
Get the USER quota (ohnielse@fysik.dtu.dk) */
@@ -474,7 +614,12 @@ BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
#endif /* USE_SETRES */
/* Use softlimit to determine disk space, except when it has been exceeded */
+#if defined(__FreeBSD__)
+ *bsize = DEV_BSIZE;
+#else /* !__FreeBSD__ */
*bsize = 1024;
+#endif /*!__FreeBSD__ */
+
if (r)
{
if (errno == EDQUOT)
diff --git a/source/smbd/server.c b/source/smbd/server.c
index 290181fb9ee..2b906a76417 100644
--- a/source/smbd/server.c
+++ b/source/smbd/server.c
@@ -711,7 +711,15 @@ int disk_free(char *path,int *bsize,int *dfree,int *dsize)
dfree_retval : dfreeq_retval ;
/* maybe dfree and dfreeq are calculated using different bsizes
so convert dfree from bsize into bsizeq */
- *dfree = ((*dfree) * (*bsize)) / (bsizeq);
+ /* avoid overflows due to multiplication, so do not:
+ *dfree = ((*dfree) * (*bsize)) / (bsizeq);
+ bsize and bsizeq are powers of 2 so its better to
+ to divide them getting a multiplication or division factor
+ for dfree. Rene Nieuwenhuizen (07-10-1997) */
+ if (*bsize >= bsizeq)
+ *dfree = *dfree * (*bsize / bsizeq);
+ else
+ *dfree = *dfree / (bsizeq / *bsize);
*dfree = ( *dfree < dfreeq ) ? *dfree : dfreeq ;
*bsize = bsizeq;
*dsize = dsizeq;
@@ -801,7 +809,15 @@ if ((*bsize) < 512 || (*bsize)>0xFFFF) *bsize = 1024;
dfree_retval : dfreeq_retval ;
/* maybe dfree and dfreeq are calculated using different bsizes
so convert dfree from bsize into bsizeq */
- *dfree = ((*dfree) * (*bsize)) / (bsizeq);
+ /* avoid overflows due to multiplication, so do not:
+ *dfree = ((*dfree) * (*bsize)) / (bsizeq);
+ bsize and bsizeq are powers of 2 so its better to
+ to divide them getting a multiplication or division factor
+ for dfree. Rene Nieuwenhuizen (07-10-1997) */
+ if (*bsize >= bsizeq)
+ *dfree = *dfree * (*bsize / bsizeq);
+ else
+ *dfree = *dfree / (bsizeq / *bsize);
*dfree = ( *dfree < dfreeq ) ? *dfree : dfreeq ;
*bsize = bsizeq;
*dsize = dsizeq;
--
cgit
From d7f41e3815babce58fa9901f076c2918666abaf9 Mon Sep 17 00:00:00 2001
From: Luke Leighton
Date: Wed, 8 Oct 1997 21:36:42 +0000
Subject: added a dummy function (space in front so make proto doesn't pick it
up) to call the unused static functions in pipes.c. avoids need to move #if
UNDEFINED_NTDOMAIN about, to stop compiler warnings while code is being
developed, but might be released as-is.
---
source/smbd/pipes.c | 1028 +--------------------------------------------------
1 file changed, 20 insertions(+), 1008 deletions(-)
diff --git a/source/smbd/pipes.c b/source/smbd/pipes.c
index 870dc16fddf..bedf847cc43 100644
--- a/source/smbd/pipes.c
+++ b/source/smbd/pipes.c
@@ -364,7 +364,6 @@ BOOL api_LsarpcTNP(int cnum,int uid, char *param,char *data,
return(True);
}
-#ifdef UNDEFINED_NTDOMAIN
/*
PAXX: Someone fix above.
The above API is indexing RPC calls based on RPC flags and
@@ -953,1011 +952,24 @@ static void api_lsa_lookup_sids( char *param, char *data,
*rdata_len = reply_len + 0x18;
}
-
-/*
- PAXX: Someone fix above.
- The above API is indexing RPC calls based on RPC flags and
- fragment length. I've decided to do it based on operation number :-)
-*/
-
-BOOL api_ntlsarpcTNP(int cnum,int uid, char *param,char *data,
- int mdrcnt,int mprcnt,
- char **rdata,char **rparam,
- int *rdata_len,int *rparam_len)
-{
- uint16 opnum;
- char *q;
- char *domainname;
- int domlen;
- pstring domsid;
- char *p;
- int numsubauths;
- int subauths[MAXSUBAUTHS];
- struct smb_passwd *smb_pass; /* To check if machine account exists */
- pstring machacct;
- pstring foo;
- uint16 infoclass;
- uint16 revision; /* Domain sid revision */
- int identauth;
- int i;
- char *logonsrv;
- char *unicomp;
- char *accountname;
- uint16 secchanneltype;
- uint32 negflags;
- char netcred[8];
- uint32 rcvcred[8];
- char rtncred[8];
- uint32 clnttime;
- uint32 rtntime;
- char *newpass;
- uint16 logonlevel;
- uint16 switchval;
- uint16 dommaxlen;
- uint16 paramcontrol;
- uint32 logonid[2];
- uint16 usernamelen;
- uint16 usernamemaxlen;
- uint16 wslen;
- uint16 wsmaxlen;
- uchar *rc4lmowfpass;
- uchar *rc4ntowfpass;
- char *domain;
- char *username;
- char *ws;
- struct uinfo *userinfo;
- int pkttype;
- ArcfourContext c;
- uchar rc4key[16];
- uchar ntowfpass[16];
- uint32 nentries;
- char *policyhandle;
- #define MAXSIDS 64
- uchar *sids[MAXSIDS]; /* for lookup SID */
- int nsids;
- int nnames;
- #define MAXNAMES 64
- uchar *names[MAXNAMES];
-
- opnum = SVAL(data,22);
-
- pkttype = CVAL(data, 2);
- if (pkttype == 0x0b) /* RPC BIND */
- {
- DEBUG(4,("netlogon rpc bind %x\n",pkttype));
- LsarpcTNP1(data,rdata,rdata_len);
- return True;
- }
-
- DEBUG(4,("ntlsa TransactNamedPipe op %x\n",opnum));
- initrpcreply(data, *rdata);
- DEBUG(4,("netlogon LINE %d\n",__LINE__));
- switch (opnum)
- {
- case LSAOPENPOLICY:
- DEBUG(1,("LSAOPENPOLICY\n"));
- DEBUG(4,("netlogon LINE %d %lx\n",__LINE__, q));
- DEBUG(4,("netlogon data %lx\n", data));
- q = *rdata + 0x18;
- DEBUG(4,("netlogon LINE %d %lx\n",__LINE__, q));
- /* return a 20 byte policy handle */
- /* here's a pretty handle:- */
- qSIVAL(time(NULL));
- qSIVAL(0x810a792f);
- qSIVAL(0x11d107d5);
- qSIVAL(time(NULL));
- qSIVAL(0x6cbcf800);
- DEBUG(4,("netlogon LINE %d %lx\n",__LINE__, q));
- endrpcreply(data, *rdata, q-*rdata, 0, rdata_len); /* size of data plus return code */
- DEBUG(4,("netlogon LINE %d %lx\n",__LINE__, q));
- break;
-
- case LSAQUERYINFOPOLICY:
- DEBUG(1,("LSAQUERYINFOPOLICY\n"));
- dump_data(1,data,128);
- infoclass = SVAL(data, 44); /* also a policy handle but who cares? */
- q = *rdata + 0x18;
- qRSIVAL(0x00000022); /* undocumented. Usually a buffer pointer whose
- value is ignored */
- qSSVAL(infoclass);
- domainname = lp_workgroup();
- domlen = strlen(domainname);
- strcpy(domsid,lp_domainsid());
- DEBUG(4,("netlogon LINE %d %lx %s\n",__LINE__, q, domsid));
- /* assume, but should check, that domsid starts "S-" */
- p = strtok(domsid+2,"-");
- revision = atoi(p);
- DEBUG(4,("netlogon LINE %d %lx %s rev %d\n",__LINE__, q, p, revision));
- identauth = atoi(strtok(0,"-"));
- DEBUG(4,("netlogon LINE %d %lx %s ia %d\n",__LINE__, q, p, identauth));
- numsubauths = 0;
- while (p = strtok(0, "-"))
- subauths[numsubauths++] = atoi(p);
- DEBUG(4,("netlogon LINE %d %lx\n",__LINE__, q));
-
- switch (infoclass)
- {
- case 5:
- case 3:
- default:
- qSSVAL(0); /* 2 undocumented bytes */
- qSSVAL(domlen*2);
- qSSVAL(domlen*2); /* unicode domain len and maxlen */
- qSIVAL(4); /* domain buffer pointer */
- qSIVAL(2); /* domain sid pointer */
- qunistr(domainname);
- qSIVAL(numsubauths);
- qSCVAL(revision);
- qSCVAL(numsubauths);
- qRSSVAL(0); /* PAXX: FIX! first 2 bytes identifier authority */
- qRSIVAL(identauth); /* next 4 bytes */
- for (i = 0; i < numsubauths; i++)
- {
- qSIVAL(subauths[i]);
- }
- }
- endrpcreply(data, *rdata, q-*rdata, 0, rdata_len);
- break;
-
- case LSAENUMTRUSTDOM:
- DEBUG(1,("LSAENUMTRUSTDOM\n"));
- q = *rdata + 0x18;
- qSIVAL(0); /* enumeration context */
- qSIVAL(0); /* entries read */
- qSIVAL(0); /* trust information */
- endrpcreply(data, *rdata, q-*rdata, 0x8000001a, rdata_len);
- break;
-
- case LSACLOSE:
- DEBUG(1,("LSACLOSE\n"));
- q = *rdata + 0x18;
- qSIVAL(0);
- qSIVAL(0);
- qSIVAL(0);
- qSIVAL(0);
- qSIVAL(0);
- endrpcreply(data, *rdata, q-*rdata, 0, rdata_len);
- break;
-
- case LSAOPENSECRET:
- DEBUG(1,("LSAOPENSECRET\n"));
- q = *rdata + 0x18;
- qSIVAL(0);
- qSIVAL(0);
- qSIVAL(0);
- qSIVAL(0);
- qSIVAL(0);
- endrpcreply(data, *rdata, q-*rdata, 0xc000034, rdata_len);
- break;
-
- case LSALOOKUPSIDS:
- DEBUG(1,("LSAOPENSECRET\n"));
- q = data + 0x18;
- policyhandle = q; q += 20;
- nentries = qIVAL;
- DEBUG(4,("lookupsid entries %d\n",nentries));
- q += (2+nentries) * 4; /* skip bufptrs */
- /* now we have nentries sids of the form:
- uint32 Subauthority count (SAC)
- char Revision
- char Subaurity count again
- char[6] Identifier authority
- [uint32 subauthority] * SAC
- */
- for (nsids = 0; nsids < nentries; nsids++)
- {
- DEBUG(4,("lookupsid q in %lx\n",q));
- sids[nsids] = q;
- DEBUG(4,("lookupsid numsubs %d\n",IVAL(q,0)));
- q += 4+1+1+6+IVAL(q,0)*4;
- DEBUG(4,("lookupsid q %lx\n",q));
- }
- /* There's 16 bytes of something after all of that, don't know
- what it is though - incorrectly documented */
-
- DEBUG(4,("lookupsid line %d\n",__LINE__));
- /* formulate reply */
- q = *rdata + 0x18;
- qSIVAL(2); /* bufptr */
- qSIVAL(4); /* number of referenced domains
- - need one per each identifier authority in call */
- qSIVAL(2); /* dom bufptr */
- qSIVAL(32); /* max entries */
- qSIVAL(4); /* number of reference domains? */
-
- qunihdr(lp_workgroup()); /* reference domain */
- qSIVAL(2); /* sid bufptr */
-
- qunihdr("S-1-1");
- qSIVAL(2); /* sid bufptr */
-
- qunihdr("S-1-5");
- qSIVAL(2); /* sid bufptr */
-
- qunihdr("S-1-3");
- qSIVAL(2); /* sid bufptr */
-
- qunistr(lp_workgroup());
- DEBUG(4,("lookupsid line %d\n",__LINE__));
-
- strcpy(domsid,lp_domainsid());
- p = strtok(domsid+2,"-");
- revision = atoi(p);
- identauth = atoi(strtok(0,"-"));
- numsubauths = 0;
- while (p = strtok(0, "-"))
- subauths[numsubauths++] = atoi(p);
- qSIVAL(numsubauths);
- qSCVAL(revision);
- qSCVAL(numsubauths);
- qRSSVAL(0); /* PAXX: FIX! first 2 bytes identifier authority */
- qRSIVAL(identauth); /* next 4 bytes */
- DEBUG(4,("lookupsid line %d\n",__LINE__));
- for (i = 0; i < numsubauths; i++)
- {
- qSIVAL(subauths[i]);
- }
- DEBUG(4,("lookupsid line %d\n",__LINE__));
-
- qunistr("S-1-1");
- qSIVAL(0); qSCVAL(1); qSCVAL(0); qRSSVAL(0); qRSIVAL(1); /* S-1-1 */
- DEBUG(4,("lookupsid line %d\n",__LINE__));
-
- qunistr("S-1-5");
- qSIVAL(0); qSCVAL(1); qSCVAL(0); qRSSVAL(0); qRSIVAL(5); /* S-1-5 */
-
- qunistr("S-1-3");
- qSIVAL(0); qSCVAL(1); qSCVAL(0); qRSSVAL(0); qRSIVAL(3); /* S-1-3 */
-
- qSIVAL(nentries);
- qSIVAL(2); /* bufptr */
- qSIVAL(nentries);
- DEBUG(4,("lookupsid line %d\n",__LINE__));
- for (i = 0; i < nentries; i++)
- {
- qSSVAL(5); /* SID name use ?! */
- qSSVAL(0); /* undocumented */
- DEBUG(4,("lookupsid line %d\n",__LINE__));
- qunihdr(sidtostring(sids[i]));
- DEBUG(4,("lookupsid sidname %s\n",sidtostring(sids[i])));
- qSIVAL(0); /* domain index out of above reference domains */
- }
- DEBUG(4,("lookupsid line %d\n",__LINE__));
- for (i = 0; i < nentries; i++)
- {
- qunistr(sidtostring(sids[i]));
- }
- qSIVAL(nentries); /* mapped count */
- endrpcreply(data, *rdata, q-*rdata, 0, rdata_len);
- break;
-
- case LSALOOKUPNAMES:
- DEBUG(1,("LSALOOKUPNAMES\n"));
- q = data + 0x18;
- policyhandle = q; q += 20;
- nentries = qIVAL;
- DEBUG(4,("lookupnames entries %d\n",nentries));
- q += 4; /* skip second count */
- q += 8 * nentries; /* skip pointers */
- for (nnames = 0; nnames < nentries; nnames++)
- {
- names[nnames] = q; /* set name string to unicode header */
- q += IVAL(q,0)*2; /* guessing here */
- }
- /* There's a translated sids structure next but it looks fals */
-
- DEBUG(4,("lookupnames line %d\n",__LINE__));
- /* formulate reply */
- q = *rdata + 0x18;
- qSIVAL(2); /* bufptr */
- qSIVAL(4); /* number of referenced domains
- - need one per each identifier authority in call */
- qSIVAL(2); /* dom bufptr */
- qSIVAL(32); /* max entries */
- qSIVAL(4); /* number of reference domains? */
-
- qunihdr(lp_workgroup()); /* reference domain */
- qSIVAL(2); /* sid bufptr */
-
- qunihdr("S-1-1");
- qSIVAL(2); /* sid bufptr */
-
- qunihdr("S-1-5");
- qSIVAL(2); /* sid bufptr */
-
- qunihdr("S-1-3");
- qSIVAL(2); /* sid bufptr */
-
- qunistr(lp_workgroup());
- DEBUG(4,("lookupnames line %d\n",__LINE__));
-
- strcpy(domsid,lp_domainsid());
- p = strtok(domsid+2,"-");
- revision = atoi(p);
- identauth = atoi(strtok(0,"-"));
- numsubauths = 0;
- while (p = strtok(0, "-"))
- subauths[numsubauths++] = atoi(p);
- qSIVAL(numsubauths);
- qSCVAL(revision);
- qSCVAL(numsubauths);
- qRSSVAL(0); /* PAXX: FIX! first 2 bytes identifier authority */
- qRSIVAL(identauth); /* next 4 bytes */
- DEBUG(4,("lookupsid line %d\n",__LINE__));
- for (i = 0; i < numsubauths; i++)
- {
- qSIVAL(subauths[i]);
- }
- DEBUG(4,("lookupsid line %d\n",__LINE__));
-
- qunistr("S-1-1");
- qSIVAL(0); qSCVAL(1); qSCVAL(0); qRSSVAL(0); qRSIVAL(1); /* S-1-1 */
- DEBUG(4,("lookupsid line %d\n",__LINE__));
-
- qunistr("S-1-5");
- qSIVAL(0); qSCVAL(1); qSCVAL(0); qRSSVAL(0); qRSIVAL(5); /* S-1-5 */
-
- qunistr("S-1-3");
- qSIVAL(0); qSCVAL(1); qSCVAL(0); qRSSVAL(0); qRSIVAL(3); /* S-1-3 */
-
- qSIVAL(nentries);
- qSIVAL(2); /* bufptr */
- qSIVAL(nentries);
- DEBUG(4,("lookupnames line %d\n",__LINE__));
- for (i = 0; i < nentries; i++)
- {
- qSSVAL(5); /* SID name use 5 == well known sid, 1 == user sid see showacls */
- qSSVAL(5); /* undocumented */
- DEBUG(4,("lookupnames line %d\n",__LINE__));
- qSIVAL(nametorid(names[i]));
- DEBUG(4,("lookupnames nametorid %d\n",nametorid(names[i])));
- qSIVAL(0); /* domain index out of above reference domains */
- }
- qSIVAL(nentries); /* mapped count */
- endrpcreply(data, *rdata, q-*rdata, 0, rdata_len);
- break;
-
- default:
- DEBUG(4, ("NTLSARPC, unknown code: %lx\n", opnum));
- }
- return(True);
-}
-
-BOOL api_netlogrpcTNP(int cnum,int uid, char *param,char *data,
- int mdrcnt,int mprcnt,
- char **rdata,char **rparam,
- int *rdata_len,int *rparam_len)
-{
- uint16 opnum;
- char *q;
- char *domainname;
- int domlen;
- pstring domsid;
- char *p;
- int numsubauths;
- int subauths[MAXSUBAUTHS];
- struct smb_passwd *smb_pass; /* To check if machine account exists */
- pstring machacct;
- pstring foo;
- uint16 infoclass;
- uint16 revision; /* Domain sid revision */
- int identauth;
- int i;
- char *logonsrv;
- char *unicomp;
- char *accountname;
- uint16 secchanneltype;
- uint32 negflags;
- char netcred[8];
- uint32 rcvcred[8];
- char rtncred[8];
- uint32 clnttime;
- uint32 rtntime;
- char *newpass;
- uint16 logonlevel;
- uint16 switchval;
- uint16 dommaxlen;
- uint16 paramcontrol;
- uint32 logonid[2];
- uint16 usernamelen;
- uint16 usernamemaxlen;
- uint16 wslen;
- uint16 wsmaxlen;
- uchar *rc4lmowfpass;
- uchar *rc4ntowfpass;
- char *domain;
- char *username;
- char *ws;
- struct uinfo *userinfo;
- int pkttype;
- ArcfourContext c;
- uchar rc4key[16];
- uchar ntowfpass[16];
-
- opnum = SVAL(data,22);
-
- pkttype = CVAL(data, 2);
- if (pkttype == 0x0b) /* RPC BIND */
- {
- DEBUG(4,("netlogon rpc bind %x\n",pkttype));
- LsarpcTNP1(data,rdata,rdata_len);
- return True;
- }
-
- DEBUG(4,("netlogon TransactNamedPipe op %x\n",opnum));
- initrpcreply(data, *rdata);
- DEBUG(4,("netlogon LINE %d\n",__LINE__));
- switch (opnum)
- {
- case LSAREQCHAL:
- DEBUG(1,("LSAREQCHAL\n"));
- q = data + 0x18;
- dump_data(1,q,128);
- logonsrv = q + 16; /* first 16 bytes, buffer ptr, + unicode lenghts */
- q = skip_unicode_string(logonsrv,1) + 12;
- q = align4(q, data);
- unicomp = q;
- q = skip_unicode_string(unicomp,1);
-
-
- DEBUG(1,("logonsrv=%s unicomp=%s\n",
- unistr(logonsrv),
- unistr(unicomp)));
-
- dcauth[cnum].chal[0] = IVAL(q, 0);
- dcauth[cnum].chal[1] = IVAL(q, 4);
- dcauth[cnum].cred[0] = IVAL(q, 0); /* this looks weird (tridge) */
- dcauth[cnum].cred[1] = IVAL(q, 4);
-
-DEBUG(1,("NL: client challenge %08x %08x\n", dcauth[cnum].chal[0],dcauth[cnum].chal[1]));
-
- /* PAXX: set these to random values */
- dcauth[cnum].svrchal[0] = 0x11111111;
- dcauth[cnum].svrchal[1] = 0x22222222;
- dcauth[cnum].svrcred[0] = 0x11111111;
- dcauth[cnum].svrcred[1] = 0x22222222;
- strcpy(machacct,unistr(unicomp));
- strcat(machacct, "$");
- smb_pass = get_smbpwnam(machacct);
- if(smb_pass)
- memcpy(dcauth[cnum].md4pw, smb_pass->smb_nt_passwd, 16);
- else
- {
- /* No such machine account. Should error out here, but we'll
- print and carry on */
- DEBUG(1,("No account in domain at REQCHAL for %s\n", machacct));
- }
- for(i=0;i<16;i++) sprintf(foo+i*2,"%02x",dcauth[cnum].md4pw[i]);
- DEBUG(1,("pass %s %s\n", machacct, foo));
- setsesskey(cnum);
- q = *rdata + 0x18;
- qSIVAL(dcauth[cnum].svrchal[0]);
- qSIVAL(dcauth[cnum].svrchal[1]);
-
-DEBUG(1,("NL: server challenge %08x %08x\n",
- dcauth[cnum].svrchal[0],dcauth[cnum].svrchal[1]));
-
- endrpcreply(data, *rdata, q-*rdata, 0, rdata_len);
- break;
-
- case LSAAUTH2:
- DEBUG(1,("LSAAUTH2\n"));
- dump_data(1,q,128);
- q = data + 0x18;
- logonsrv = q + 16;
- q = skip_unicode_string(logonsrv,1)+12;
- q = align4(q, data);
- accountname = q;
-
- q = skip_unicode_string(accountname,1);
- secchanneltype = qSVAL;
- q += 12;
- q = align4(q, data);
- unicomp = q;
- dump_data(1,unicomp,32);
- q = skip_unicode_string(unicomp,1);
- rcvcred[0] = qIVAL;
- rcvcred[1] = qIVAL;
- q = align4(q, data);
- negflags = qIVAL;
- DEBUG(3,("AUTH2 logonsrv=%s accountname=%s unicomp=%s %lx %lx %lx\n",
- unistr(logonsrv), unistr(accountname), unistr(unicomp),
- rcvcred[0], rcvcred[1], negflags));
-
-DEBUG(1,("NL: recvcred %08x %08x negflags=%08x\n",
- rcvcred[0], rcvcred[1], negflags));
-
- checkcred(cnum, rcvcred[0], rcvcred[1], 0);
- q = *rdata + 0x18;
- makecred(cnum, 0, q);
- q += 8;
-
- qSIVAL(negflags);
- /* update stored client credentials */
- dcauth[cnum].cred[0] = dcauth[cnum].svrcred[0] = rcvcred[0];
- dcauth[cnum].cred[1] = dcauth[cnum].svrcred[1] = rcvcred[1];
- endrpcreply(data, *rdata, q-*rdata, 0, rdata_len);
- break;
-
- case LSASVRPWSET:
- DEBUG(1,("LSASVRPWSET\n"));
- q = data + 0x18;
- dump_data(1,q,128);
- logonsrv = q + 16;
- q = skip_unicode_string(logonsrv,1)+12;
- q = align4(q, data);
- accountname = q;
- q = skip_unicode_string(accountname,1);
- secchanneltype = qSVAL;
- q += 12;
- q = align4(q, data);
- unicomp = q;
- q = skip_unicode_string(unicomp,1);
- rcvcred[0] = qIVAL;
- rcvcred[1] = qIVAL;
- clnttime = qIVAL;
-
- DEBUG(1,("PWSET logonsrv=%s accountname=%s unicomp=%s\n",
- unistr(logonsrv), unistr(accountname), unistr(unicomp)));
-
- checkcred(cnum, rcvcred[0], rcvcred[1], clnttime);
- DEBUG(3,("PWSET %lx %lx %lx %lx\n", rcvcred[0], rcvcred[1], clnttime, negflags));
- newpass = q;
-
- DEBUG(1,("PWSET logonsrv=%s accountname=%s unicomp=%s newpass=%s\n",
- unistr(logonsrv), unistr(accountname), unistr(unicomp), newpass));
-
- /* PAXX: For the moment we'll reject these */
- /* TODO Need to set newpass in smbpasswd file for accountname */
- q = *rdata + 0x18;
- makecred(cnum, clnttime+1, q);
- q += 8;
- qSIVAL(0); /* timestamp. Seems to be ignored */
-
- dcauth[cnum].svrcred[0] = dcauth[cnum].cred[0] = dcauth[cnum].cred[0] + clnttime + 1;
-
- endrpcreply(data, *rdata, q-*rdata, 0xc000006a, rdata_len);
- break;
-
- case LSASAMLOGON:
- DEBUG(1,("LSASAMLOGON\n"));
- dump_data(1,data,128);
- q = data + 0x18;
- logonsrv = q + 16;
- DEBUG(1,("SMLOG %d\n", __LINE__));
- q = skip_unicode_string(logonsrv,1)+16;
- q = align4(q, data);
- unicomp = q;
- q = skip_unicode_string(unicomp,1)+4;
- DEBUG(1,("SMLOG %d logonsrv=%s unicomp=%s\n",
- __LINE__, unistr(logonsrv), unistr(unicomp)));
- q = align4(q, data);
- rcvcred[0] = qIVAL;
- DEBUG(1,("SMLOG %d\n", __LINE__));
- rcvcred[1] = qIVAL;
- DEBUG(1,("SMLOG %d\n", __LINE__));
- clnttime = qIVAL;
- checkcred(cnum, rcvcred[0], rcvcred[1], clnttime);
- q += 2;
- rtncred[0] = qIVAL; /* all these are ignored */
- DEBUG(1,("SMLOG %d\n", __LINE__));
- rtncred[1] = qIVAL;
- rtntime = qIVAL;
- logonlevel = qSVAL;
- DEBUG(1,("SMLOG %d\n", __LINE__));
- switchval = qSVAL;
- switch (switchval)
- {
- case 1:
-
- q += 6;
- domlen = qSVAL;
- dommaxlen = qSVAL; q += 4;
- paramcontrol = qIVAL;
- logonid[0] = qIVAL; /* low part */
- logonid[1] = qIVAL; /* high part */
-
- usernamelen = qSVAL;
-
- DEBUG(1,("SMLOG %d\n", __LINE__));
- usernamemaxlen = qSVAL; q += 4;
-
- DEBUG(1,("usernamelen=%d maxlen=%d dommaxlen=%d\n",
- usernamelen, usernamemaxlen, dommaxlen));
-
- dump_data(1,q,128);
-
- wslen = qSVAL;
- wsmaxlen = qSVAL; q += 4;
- rc4lmowfpass = q; q += 16;
- rc4ntowfpass = q; q += 16;
-
- q += 12; domain = q; q += dommaxlen + 12;
- q = align4(q, data);
- username = q; q += usernamemaxlen + 12;
- q = align4(q, data);
- ws = q;
- DEBUG(1,("domain=%s username=%s ws=%s\n",
- unistr(domain), unistr(username),
- unistr(ws)));
- break;
- default:
- DEBUG(0,("unknown switch in SAMLOGON %d\n",
- switchval));
- }
- for(i=0;i<16;i++) sprintf(foo+i*2,"%02x",username[i]);
- DEBUG(1,("userNAME %s [%s]\n", foo, username));
- DEBUG(1,("SMLOG %d\n", __LINE__));
- q = *rdata + 0x18;
- qSIVAL(0x16a4b4); /* magic buffer pointer ? */
- makecred(cnum, clnttime+1, q);
- dcauth[cnum].svrcred[0] = dcauth[cnum].cred[0] = dcauth[cnum].cred[0] + clnttime + 1;
- q += 8;
- qSIVAL(0); /* timestamp. client doesn't care */
- qSSVAL(3); /* switch value 3. May be others? */
- qSSVAL(0); /* undocumented */
- DEBUG(1,("SMLOG %d\n", __LINE__));
-
- memset(rc4key, 0, sizeof rc4key);
- SIVAL(rc4key, 0, dcauth[cnum].sesskey[0]);
- SIVAL(rc4key, 4, dcauth[cnum].sesskey[1]);
- for(i=0;i<16;i++) sprintf(foo+i*2,"%02x",rc4ntowfpass[i]);
- DEBUG(1,("rc4ntowf %s\n", foo));
- arcfour_init(&c, rc4key, sizeof rc4key);
- arcfour_encrypt(&c, ntowfpass, rc4ntowfpass, sizeof ntowfpass);
- for(i=0;i<16;i++) sprintf(foo+i*2,"%02x",ntowfpass[i]);
- DEBUG(1,("ntowf %s\n", foo));
-
- if(!(userinfo = getuserinfo(username, usernamelen, ntowfpass))) {
- qSIVAL(0); /* no buffer */
- qSCVAL(1); /* Authoratitive. Change if passthrough? */
- qSCVAL(0); /* pad for above boolean */
- qSSVAL(0); /* pad for above boolean */
-
- endrpcreply(data, *rdata, q-*rdata, 0xc0000064, rdata_len);
- break;
- }
-
- qSIVAL(2); /* another magic bufptr? */
- DEBUG(1,("SMLOG %d %lx\n", __LINE__, userinfo));
- qSIVAL(userinfo->logontime[0]); qSIVAL(userinfo->logontime[1]);
- qSIVAL(userinfo->logofftime[0]); qSIVAL(userinfo->logofftime[1]);
- DEBUG(1,("SMLOG %d %lx\n", __LINE__, userinfo->passlastsettime[1]));
- qSIVAL(userinfo->kickofftime[0]); qSIVAL(userinfo->kickofftime[1]);
- qSIVAL(userinfo->passlastsettime[0]); qSIVAL(userinfo->passlastsettime[1]);
- qSIVAL(userinfo->passcanchgtime[0]); qSIVAL(userinfo->passcanchgtime[1]);
- qSIVAL(userinfo->passmustchgtime[0]); qSIVAL(userinfo->passmustchgtime[1]);
- DEBUG(1,("SMLOG %d %s\n", __LINE__, userinfo->effectivename));
- qunihdr(userinfo->effectivename);
- qunihdr(userinfo->fullname);
- DEBUG(1,("SMLOG %d\n", __LINE__));
- qunihdr(userinfo->logonscript);
- qunihdr(userinfo->profilepath);
- qunihdr(userinfo->homedirectory);
- qunihdr(userinfo->homedirectorydrive);
- DEBUG(1,("SMLOG %d\n", __LINE__));
- qSSVAL(userinfo->logoncount);
- qSSVAL(userinfo->badpwcount);
- qSIVAL(userinfo->uid);
- qSIVAL(userinfo->gid);
- DEBUG(1,("SMLOG %d\n", __LINE__));
- qSIVAL(userinfo->ngroups);
- qSIVAL(8); /* ptr to groups */
- qSIVAL(userinfo->userflags);
- DEBUG(1,("SMLOG %d\n", __LINE__));
- qSIVAL(0); qSIVAL(0); qSIVAL(0); qSIVAL(0); /* unused user session key */
- qunihdr(userinfo->logonserver);
- qunihdr(userinfo->logondomain);
- DEBUG(1,("SMLOG %d\n", __LINE__));
- qSIVAL(2); /* logon domain id ptr */
- DEBUG(1,("SMLOG %d\n", __LINE__));
- memset(q,0,40); q += 40; /* expansion room */
- DEBUG(1,("SMLOG %d\n", __LINE__));
- qSIVAL(userinfo->nsids);
- DEBUG(1,("SMLOG %d\n", __LINE__));
- qSIVAL(0); /* ptr to sids and values */
- DEBUG(1,("SMLOG %d\n", __LINE__));
- qunistr(userinfo->effectivename);
- DEBUG(1,("SMLOG %d\n", __LINE__));
- qunistr(userinfo->fullname);
- DEBUG(1,("SMLOG %d\n", __LINE__));
- qunistr(userinfo->logonscript);
- DEBUG(1,("SMLOG %d\n", __LINE__));
- qunistr(userinfo->profilepath);
- qunistr(userinfo->homedirectory);
- qunistr(userinfo->homedirectorydrive);
- DEBUG(1,("SMLOG %d\n", __LINE__));
- qSIVAL(userinfo->ngroups);
- for (i = 0; i < userinfo->ngroups; i++)
- {
- qSIVAL(userinfo->groups[i].gid);
- qSIVAL(userinfo->groups[i].attr);
- }
- qunistr(userinfo->logonserver);
- qunistr(userinfo->logondomain);
- for (i = 0; i < userinfo->nsids; i++)
- {
- /* put the extra sids: PAXX: TODO */
- }
- /* Assumption. This is the only domain, sending our SID */
- /* PAXX: may want to do passthrough later */
- strcpy(domsid,lp_domainsid());
- DEBUG(4,("netlogon LINE %d %lx %s\n",__LINE__, q, domsid));
- /* assume, but should check, that domsid starts "S-" */
- p = strtok(domsid+2,"-");
- revision = atoi(p);
- DEBUG(4,("netlogon LINE %d %lx %s rev %d\n",__LINE__, q, p, revision));
- identauth = atoi(strtok(0,"-"));
- DEBUG(4,("netlogon LINE %d %lx %s ia %d\n",__LINE__, q, p, identauth));
- numsubauths = 0;
- while (p = strtok(0, "-"))
- subauths[numsubauths++] = atoi(p);
- qSIVAL(numsubauths);
- qSCVAL(revision);
- qSCVAL(numsubauths);
- qRSSVAL(0); /* PAXX: FIX. first 2 bytes identifier authority */
- qRSIVAL(identauth); /* next 4 bytes */
- DEBUG(1,("SMLOG %d\n", __LINE__));
- for (i = 0; i < numsubauths; i++)
- {
- qSIVAL(subauths[i]);
- }
- qSCVAL(1); /* Authoratitive. Change if passthrough? */
- qSCVAL(0); /* pad for above boolean */
- qSSVAL(0); /* pad for above boolean */
-
- endrpcreply(data, *rdata, q-*rdata, 0, rdata_len);
- break;
-
- case LSASAMLOGOFF:
- DEBUG(1,("LSASAMLOGOFF\n"));
- q = data + 0x18;
- logonsrv = q + 16;
- DEBUG(1,("SAMLOGOFF %d\n", __LINE__));
- unicomp = skip_unicode_string(logonsrv,1)+16;
- if (strlen(unistr(logonsrv)) % 2 == 0)
- q += 2;
- DEBUG(1,("SMLOG %d\n", __LINE__));
- q = skip_unicode_string(unicomp,1)+4;
- if (strlen(unistr(unicomp)) % 2 == 0)
- q += 2;
- DEBUG(1,("SMLOG %d\n", __LINE__));
- rcvcred[0] = qIVAL;
- DEBUG(1,("SMLOG %d\n", __LINE__));
- rcvcred[1] = qIVAL;
- DEBUG(1,("SMLOG %d\n", __LINE__));
- clnttime = qIVAL;
- checkcred(cnum, rcvcred[0], rcvcred[1], clnttime);
- q += 4;
- rtncred[0] = qIVAL; /* all these are ignored */
- DEBUG(1,("SMLOG %d\n", __LINE__));
- rtncred[1] = qIVAL;
- rtntime = qIVAL;
- logonlevel = qSVAL;
- DEBUG(1,("SMLOG %d\n", __LINE__));
- switchval = qSVAL;
- switch (switchval)
- {
- case 1:
- q += 4;
- domlen = qSVAL;
- dommaxlen = qSVAL; q += 4;
- paramcontrol = qIVAL;
- logonid[0] = qIVAL; /* low part */
- logonid[1] = qIVAL; /* high part */
- usernamelen = qSVAL;
- DEBUG(1,("SMLOG %d\n", __LINE__));
- usernamemaxlen = qSVAL; q += 4;
- wslen = qSVAL;
- wsmaxlen = qSVAL; q += 4;
- rc4lmowfpass = q; q += 16;
- rc4ntowfpass = q; q += 16;
- q += 12; domain = q; q += dommaxlen + 12;
- if ((domlen/2) % 2 != 0) q += 2;
- username = q; q += usernamemaxlen + 12; /* PAXX: HACK */
- if ((usernamelen/2) % 2 != 0) q += 2;
- ws = q;
- break;
- default: DEBUG(0, ("unknown switch in SAMLOGON %d\n",switchval));
- }
- DEBUG(1,("SAMLOGOFF %s\n", unistr(username)));
- default:
- DEBUG(4, ("**** netlogon, unknown code: %lx\n", opnum));
- }
- return(True);
+/* space in front of this function so that make proto doesn't pick it up */
+ void _dummy_function(void)
+{
+ UTIME t;
+ lsa_reply_req_chal(NULL, NULL, NULL, NULL);
+ lsa_reply_auth_2(NULL, NULL, NULL, NULL, 0);
+ lsa_reply_srv_pwset(NULL, NULL, NULL, NULL, t, 0);
+ make_lsa_user_info(NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL,
+ 0, 0,
+ 0, 0, 0, NULL, 0,
+ NULL,
+ NULL, NULL,
+ NULL, NULL);
+ lsa_reply_sam_logon(NULL,NULL,NULL,NULL,t, NULL);
+ lsa_reply_sam_logoff(NULL,NULL,NULL,NULL,t,0);
+ api_lsa_open_policy(NULL,NULL,NULL,NULL);
+ api_lsa_query_info(NULL,NULL,NULL,NULL);
+ api_lsa_lookup_sids(NULL,NULL,NULL,NULL);
}
-
-void initrpcreply(char *inbuf, char *q)
-{
- uint32 callid;
-
- qSCVAL(5); /* RPC version 5 */
- qSCVAL(0); /* minor version 0 */
- qSCVAL(2); /* RPC response packet */
- qSCVAL(3); /* first frag + last frag */
- qRSIVAL(0x10000000); /* packed data representation */
- qRSSVAL(0); /* fragment length, fill in later */
- qSSVAL(0); /* authentication length */
- callid = RIVAL(inbuf,12);
- qRSIVAL(callid); /* call identifier - match incoming RPC */
- qSIVAL(0x18); /* allocation hint (no idea) */
- qSSVAL(0); /* presentation context identifier */
- qSCVAL(0); /* cancel count */
- qSCVAL(0); /* reserved */
-}
-
-endrpcreply(char *inbuf, char *q, int datalen, int rtnval, int *rlen)
-{
- SSVAL(q, 8, datalen + 4);
- SIVAL(q,0x10,datalen+4-0x18); /* allocation hint */
- SIVAL(q, datalen, rtnval);
- *rlen = datalen + 4;
- {int fd; fd = open("/tmp/rpc", O_RDWR);write(fd,q,datalen+4);}
-}
-
-void setsesskey(int cnum)
-{
- uint32 sum[2];
- char netsum[8];
- char netsesskey[8];
- char icv[8];
-
- sum[0] = dcauth[cnum].chal[0] + dcauth[cnum].svrchal[0];
- sum[1] = dcauth[cnum].chal[1] + dcauth[cnum].svrchal[1];
- SIVAL(netsum,0,sum[0]);
- SIVAL(netsum,4,sum[1]);
- E1(dcauth[cnum].md4pw,netsum,icv);
- E1(dcauth[cnum].md4pw+9,icv,netsesskey);
- dcauth[cnum].sesskey[0] = IVAL(netsesskey,0);
- dcauth[cnum].sesskey[1] = IVAL(netsesskey,4);
-
-DEBUG(1,("NL: session key %08x %08x\n",
- dcauth[cnum].sesskey[0],
- dcauth[cnum].sesskey[1]));
-}
-
-void checkcred(int cnum, uint32 cred0, uint32 cred1, uint32 time)
-{
- uint32 sum[2];
- char netdata[8];
- char netsesskey[8];
- char calccred[8];
- char icv[8];
- char key2[7];
-
- SIVAL(netdata, 0, dcauth[cnum].cred[0]+time);
- SIVAL(netdata, 4, dcauth[cnum].cred[1]);
- SIVAL(netsesskey, 0, dcauth[cnum].sesskey[0]);
- SIVAL(netsesskey, 4, dcauth[cnum].sesskey[1]);
- E1(netsesskey,netdata,icv);
- memset(key2, 0, sizeof key2);
- key2[0] = netsesskey[7];
- E1(key2, icv, calccred);
- if (IVAL(calccred,0) != cred0 ||
- IVAL(calccred,4) != cred1)
- {
- DEBUG(1,("Incorrect client credential received cred %lx %lx time %lx sk %lx %lx cred %lx %lx expcred %lx %lx\n",
- cred0, cred1, time,
- dcauth[cnum].sesskey[0], dcauth[cnum].sesskey[1],
- dcauth[cnum].cred[0], dcauth[cnum].cred[1],
- IVAL(calccred,0), IVAL(calccred,4)));
- /* PAXX: do something about it! */
- } else
- DEBUG(4,("Correct client credential received chal %lx %lx time %lx sk %lx %lx cred %lx %lx expcred %lx %lx\n",
- cred0, cred1, time,
- dcauth[cnum].sesskey[0], dcauth[cnum].sesskey[1],
- dcauth[cnum].cred[0], dcauth[cnum].cred[1],
- IVAL(calccred,0), IVAL(calccred,4)));
-}
-
-void makecred(int cnum, uint32 time, char *calccred)
-{
- uint32 sum[2];
- char netdata[8];
- char netsesskey[8];
- char icv[8];
- char key2[7];
-
- SIVAL(netdata, 0, dcauth[cnum].svrcred[0]+time);
- SIVAL(netdata, 4, dcauth[cnum].svrcred[1]);
- SIVAL(netsesskey, 0, dcauth[cnum].sesskey[0]);
- SIVAL(netsesskey, 4, dcauth[cnum].sesskey[1]);
- E1(netsesskey,netdata,icv);
- memset(key2, 0, sizeof key2);
- key2[0] = netsesskey[7];
- E1(key2, icv, calccred);
- DEBUG(4,("Server credential: chal %lx %lx sk %lx %lx cred %lx %lx calc %lx %lx\n",
- dcauth[cnum].svrchal[0], dcauth[cnum].svrchal[1],
- dcauth[cnum].sesskey[0], dcauth[cnum].sesskey[1],
- dcauth[cnum].svrcred[0], dcauth[cnum].svrcred[1],
- IVAL(calccred, 0), IVAL(calccred, 4)));
-}
-
-
-struct uinfo *getuserinfo(char *user, int len, char *ntowfpass)
-{
- static struct uinfo u;
- static pstring fullnm;
- static pstring ascuser;
- extern pstring myname;
- static pstring stme;
- static pstring stdom;
- struct smb_passwd *smb_pass;
-
- strcpy(ascuser,unistr(user));
- ascuser[len/2] = 0; /* PAXX: FIXMEFIXMEFIXME */
- DEBUG(1,("GETUSER username :%s: len=%d\n",ascuser, len));
-
- smb_pass = get_smbpwnam(ascuser);
- if(!smb_pass)
- return 0;
- DEBUG(1,("GETU %d\n", __LINE__));
- if (memcmp(ntowfpass, smb_pass->smb_nt_passwd, 16)) {
- DEBUG(1,("pass mismatch:\n"));
- dump_data(1,ntowfpass,16);
- dump_data(1,smb_pass->smb_nt_passwd,16);
- return 0;
- }
-
- DEBUG(1,("GETU %d\n", __LINE__));
- u.logontime[0] = 0xffffffff; u.logontime[1] = 0x7fffffff;
- u.logofftime[0] = 0xffffffff; u.logofftime[1] = 0x7fffffff;
- u.kickofftime[0] = 0xffffffff; u.kickofftime[1] = 0x7fffffff;
- DEBUG(1,("GETU %d\n", __LINE__));
- u.passlastsettime[0] = 0xffffffff; u.passlastsettime[1] = 0x7fffffff;
- u.passcanchgtime[0] = 0xffffffff; u.passcanchgtime[1] = 0x7fffffff;
- u.passmustchgtime[0] = 0xffffffff; u.passmustchgtime[1] = 0x7fffffff;
- DEBUG(1,("GETU %d\n", __LINE__));
- u.effectivename = ascuser;
- strcpy(fullnm, "Full name of ");
- strcat(fullnm, ascuser);
- DEBUG(1,("GETU %d\n", __LINE__));
- u.fullname = fullnm;
- u.logonscript = "foologin.cmd";
- u.profilepath = "prof";
- u.homedirectory = "foohomes";
- DEBUG(1,("GETU %d\n", __LINE__));
- u.homedirectorydrive = "a:";
- u.logoncount = 7;
- u.badpwcount = 8;
- u.uid = 778;
- DEBUG(1,("GETU %d\n", __LINE__));
- u.gid = 998;
- u.ngroups = 2;
- u.groups = (struct groupinfo *)(malloc(sizeof (struct groupinfo) * 2));
- u.groups[0].gid = 776;
- DEBUG(1,("GETU %d\n", __LINE__));
- u.groups[0].attr = 0x7;
- u.groups[1].gid = 776;
- u.groups[1].attr = 0x7;
- u.userflags = 0x20;
- u.logonserver = stme;
- get_myname(myname,NULL);
- strcpy(stme, myname);
- strupper(stme);
- DEBUG(1,("LS %s\n", u.logonserver));
- u.logondomain = stdom;
- strcpy(stdom, lp_workgroup());
- strupper(stdom);
- DEBUG(1,("DOM %s\n", u.logondomain));
- u.nsids = 0;
- u.sids = 0;
- DEBUG(1,("GETU %d\n", __LINE__));
- return &u;
-};
-
-int
-nametorid(char *uniuser)
-{
- if (!strncmp(unistr(uniuser+12),"ashtonp",7))
- return 2000;
- if (!strncmp(unistr(uniuser+12),"user1",5))
- return 1;
- if (!strncmp(unistr(uniuser+12),"user2",5))
- return 10;
- if (!strncmp(unistr(uniuser+12),"user3",5))
- return 100;
- return 3000;
-}
-
-#endif /* NTDOMAIN */
--
cgit
From fa69b3dda47d56e0c3ce1f4f284eac89d4b4bf56 Mon Sep 17 00:00:00 2001
From: Jeremy Allison
Date: Wed, 8 Oct 1997 22:23:47 +0000
Subject: Put in fix for read-prediction extending files bug. Hard to test,
can't get read-prediction to happen :-). Jeremy (jallison@whistle.com)
---
source/smbd/predict.c | 39 ++++++++++++++++++++++++++-------------
1 file changed, 26 insertions(+), 13 deletions(-)
diff --git a/source/smbd/predict.c b/source/smbd/predict.c
index 691d8fbb4e0..7d6b2498f5a 100644
--- a/source/smbd/predict.c
+++ b/source/smbd/predict.c
@@ -53,24 +53,37 @@ int read_predict(int fd,int offset,char *buf,char **ptr,int num)
offset >= rp_offset &&
possible>0 &&
smb_last_time-rp_time < rp_timeout)
- {
- ret = possible;
- if (buf)
- memcpy(buf,rp_buffer + (offset-rp_offset),possible);
- else
- *ptr = rp_buffer + (offset-rp_offset);
- DEBUG(5,("read-prediction gave %d bytes of %d\n",ret,num));
- }
+ {
+ ret = possible;
+ if (buf)
+ memcpy(buf,rp_buffer + (offset-rp_offset),possible);
+ else
+ *ptr = rp_buffer + (offset-rp_offset);
+ DEBUG(5,("read-prediction gave %d bytes of %d\n",ret,num));
+ }
if (ret == num) {
predict_skip = True;
} else {
- predict_skip = False;
+ struct stat rp_stat;
+
+ /* Find the end of the file - ensure we don't
+ read predict beyond it. */
+ if(fstat(fd,&rp_stat) < 0)
+ {
+ DEBUG(0,("read-prediction failed on fstat. Error was %s\n", strerror(errno)));
+ predict_skip = True;
+ }
+ else
+ {
+ predict_skip = False;
- /* prepare the next prediction */
- rp_predict_fd = fd;
- rp_predict_offset = offset + num;
- rp_predict_length = num;
+ /* prepare the next prediction */
+ rp_predict_fd = fd;
+ /* Make sure we don't seek beyond the end of the file. */
+ rp_predict_offset = MIN((offset + num),rp_stat.st_size);
+ rp_predict_length = num;
+ }
}
if (ret < 0) ret = 0;
--
cgit
From 2614cd1d35ab53e952e5bcfbb1d50b0feeefeeb6 Mon Sep 17 00:00:00 2001
From: Jeremy Allison
Date: Thu, 9 Oct 1997 00:43:55 +0000
Subject: predict.c: stop lseek from extending file. Hard to test. proto.h:
updated. quotas.c: Added FreeBSD fixes. server.c: Added quota overflow fix
for large filesystems. Rolled back to old error codes. Jeremy
(jallison@whistle.com)
---
source/smbd/predict.c | 39 ++++++++++++++++++++++++++-------------
source/smbd/quotas.c | 27 ++++++++++++++++++++++++++-
source/smbd/server.c | 30 ++++++++++++++++++++++++++++--
3 files changed, 80 insertions(+), 16 deletions(-)
diff --git a/source/smbd/predict.c b/source/smbd/predict.c
index 691d8fbb4e0..7d6b2498f5a 100644
--- a/source/smbd/predict.c
+++ b/source/smbd/predict.c
@@ -53,24 +53,37 @@ int read_predict(int fd,int offset,char *buf,char **ptr,int num)
offset >= rp_offset &&
possible>0 &&
smb_last_time-rp_time < rp_timeout)
- {
- ret = possible;
- if (buf)
- memcpy(buf,rp_buffer + (offset-rp_offset),possible);
- else
- *ptr = rp_buffer + (offset-rp_offset);
- DEBUG(5,("read-prediction gave %d bytes of %d\n",ret,num));
- }
+ {
+ ret = possible;
+ if (buf)
+ memcpy(buf,rp_buffer + (offset-rp_offset),possible);
+ else
+ *ptr = rp_buffer + (offset-rp_offset);
+ DEBUG(5,("read-prediction gave %d bytes of %d\n",ret,num));
+ }
if (ret == num) {
predict_skip = True;
} else {
- predict_skip = False;
+ struct stat rp_stat;
+
+ /* Find the end of the file - ensure we don't
+ read predict beyond it. */
+ if(fstat(fd,&rp_stat) < 0)
+ {
+ DEBUG(0,("read-prediction failed on fstat. Error was %s\n", strerror(errno)));
+ predict_skip = True;
+ }
+ else
+ {
+ predict_skip = False;
- /* prepare the next prediction */
- rp_predict_fd = fd;
- rp_predict_offset = offset + num;
- rp_predict_length = num;
+ /* prepare the next prediction */
+ rp_predict_fd = fd;
+ /* Make sure we don't seek beyond the end of the file. */
+ rp_predict_offset = MIN((offset + num),rp_stat.st_size);
+ rp_predict_length = num;
+ }
}
if (ret < 0) ret = 0;
diff --git a/source/smbd/quotas.c b/source/smbd/quotas.c
index d4f746c9e36..2d238dfaf17 100644
--- a/source/smbd/quotas.c
+++ b/source/smbd/quotas.c
@@ -416,10 +416,12 @@ BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
}
return (True);
}
+
#else
#ifdef __FreeBSD__
#include
+#include
#elif AIX
/* AIX quota patch from Ole Holm Nielsen */
#include
@@ -463,7 +465,25 @@ BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
}
#else /* USE_SETRES */
#if defined(__FreeBSD__)
- r= quotactl(path,Q_GETQUOTA,euser_id,(char *) &D);
+ {
+ /* FreeBSD patches from Marty Moll */
+ uid_t user_id;
+ gid_t egrp_id;
+
+ /* Need to be root to get quotas in FreeBSD */
+ user_id = getuid();
+ egrp_id = getegid();
+ setuid(0);
+ seteuid(0);
+ r= quotactl(path,QCMD(Q_GETQUOTA,USRQUOTA),euser_id,(char *) &D);
+
+ /* As FreeBSD has group quotas, if getting the user
+ quota fails, try getting the group instead. */
+ if (r)
+ r= quotactl(path,QCMD(Q_GETQUOTA,GRPQUOTA),egrp_id,(char *) &D);
+ setuid(user_id);
+ seteuid(euser_id);
+ }
#elif defined(AIX)
/* AIX has both USER and GROUP quotas:
Get the USER quota (ohnielse@fysik.dtu.dk) */
@@ -474,7 +494,12 @@ BOOL disk_quotas(char *path, int *bsize, int *dfree, int *dsize)
#endif /* USE_SETRES */
/* Use softlimit to determine disk space, except when it has been exceeded */
+#if defined(__FreeBSD__)
+ *bsize = DEV_BSIZE;
+#else /* !__FreeBSD__ */
*bsize = 1024;
+#endif /*!__FreeBSD__ */
+
if (r)
{
if (errno == EDQUOT)
diff --git a/source/smbd/server.c b/source/smbd/server.c
index 35a7c730be4..8e1bc152ffd 100644
--- a/source/smbd/server.c
+++ b/source/smbd/server.c
@@ -703,7 +703,15 @@ int disk_free(char *path,int *bsize,int *dfree,int *dsize)
dfree_retval : dfreeq_retval ;
/* maybe dfree and dfreeq are calculated using different bsizes
so convert dfree from bsize into bsizeq */
- *dfree = ((*dfree) * (*bsize)) / (bsizeq);
+ /* avoid overflows due to multiplication, so do not:
+ *dfree = ((*dfree) * (*bsize)) / (bsizeq);
+ bsize and bsizeq are powers of 2 so its better to
+ to divide them getting a multiplication or division factor
+ for dfree. Rene Nieuwenhuizen (07-10-1997) */
+ if (*bsize >= bsizeq)
+ *dfree = *dfree * (*bsize / bsizeq);
+ else
+ *dfree = *dfree / (bsizeq / *bsize);
*dfree = ( *dfree < dfreeq ) ? *dfree : dfreeq ;
*bsize = bsizeq;
*dsize = dsizeq;
@@ -793,7 +801,15 @@ if ((*bsize) < 512 || (*bsize)>0xFFFF) *bsize = 1024;
dfree_retval : dfreeq_retval ;
/* maybe dfree and dfreeq are calculated using different bsizes
so convert dfree from bsize into bsizeq */
- *dfree = ((*dfree) * (*bsize)) / (bsizeq);
+ /* avoid overflows due to multiplication, so do not:
+ *dfree = ((*dfree) * (*bsize)) / (bsizeq);
+ bsize and bsizeq are powers of 2 so its better to
+ to divide them getting a multiplication or division factor
+ for dfree. Rene Nieuwenhuizen (07-10-1997) */
+ if (*bsize >= bsizeq)
+ *dfree = *dfree * (*bsize / bsizeq);
+ else
+ *dfree = *dfree / (bsizeq / *bsize);
*dfree = ( *dfree < dfreeq ) ? *dfree : dfreeq ;
*bsize = bsizeq;
*dsize = dsizeq;
@@ -1963,7 +1979,11 @@ struct
{EPERM,ERRDOS,ERRnoaccess},
{EACCES,ERRDOS,ERRnoaccess},
{ENOENT,ERRDOS,ERRbadfile},
+#if 0 /* Go back to old method for now. */
{ENOTDIR,ERRDOS,ERRbaddirectory},
+#else
+ {ENOTDIR,ERRDOS,ERRbadpath},
+#endif
{EIO,ERRHRD,ERRgeneral},
{EBADF,ERRSRV,ERRsrverror},
{EINVAL,ERRSRV,ERRsrverror},
@@ -1984,6 +2004,7 @@ struct
{0,0,0}
};
+#if 0 /* Go back to old method for now. */
/* Mapping for old clients. */
struct
@@ -1998,6 +2019,8 @@ struct
{0,0,0}
};
+#endif /* Go back to old method for now. */
+
/****************************************************************************
create an error packet from errno
****************************************************************************/
@@ -2028,6 +2051,8 @@ int unix_error_packet(char *inbuf,char *outbuf,int def_class,uint32 def_code,int
}
}
+#if 0 /* Go back to old method for now. */
+
/* Make sure we don't return error codes that old
clients don't understand. */
@@ -2050,6 +2075,7 @@ int unix_error_packet(char *inbuf,char *outbuf,int def_class,uint32 def_code,int
break;
}
}
+#endif /* Go back to old method for now. */
return(error_packet(inbuf,outbuf,eclass,ecode,line));
}
--
cgit
From e789179dfda669bd768720cb3732cf56a49027b5 Mon Sep 17 00:00:00 2001
From: "Christopher R. Hertel"
Date: Thu, 9 Oct 1997 04:09:56 +0000
Subject: This is my library of lists and trees. My hope is to replace all of
the hard coded linked lists that are currently used in Samba with calls to
these modules. This should make the code simpler, smaller, and (I hope)
faster. The tree code, in particular, should speed up processing where large
lists are involved.
Chris -)-----
---
source/ubi_AVLtree.c | 699 ++++++++++++++++++++++++++++++++
source/ubi_AVLtree.h | 340 ++++++++++++++++
source/ubi_BinTree.c | 1042 ++++++++++++++++++++++++++++++++++++++++++++++++
source/ubi_BinTree.h | 745 ++++++++++++++++++++++++++++++++++
source/ubi_SplayTree.c | 472 ++++++++++++++++++++++
source/ubi_SplayTree.h | 339 ++++++++++++++++
source/ubi_dLinkList.c | 152 +++++++
source/ubi_dLinkList.h | 163 ++++++++
8 files changed, 3952 insertions(+)
create mode 100644 source/ubi_AVLtree.c
create mode 100644 source/ubi_AVLtree.h
create mode 100644 source/ubi_BinTree.c
create mode 100644 source/ubi_BinTree.h
create mode 100644 source/ubi_SplayTree.c
create mode 100644 source/ubi_SplayTree.h
create mode 100644 source/ubi_dLinkList.c
create mode 100644 source/ubi_dLinkList.h
diff --git a/source/ubi_AVLtree.c b/source/ubi_AVLtree.c
new file mode 100644
index 00000000000..730392a472a
--- /dev/null
+++ b/source/ubi_AVLtree.c
@@ -0,0 +1,699 @@
+/* ========================================================================== **
+ * ubi_AVLtree.c
+ *
+ * Copyright (C) 1991-1997 by Christopher R. Hertel
+ *
+ * Email: crh@ubiqx.mn.org
+ * -------------------------------------------------------------------------- **
+ *
+ * This module provides an implementation of AVL height balanced binary
+ * trees. (Adelson-Velskii, Landis 1962)
+ *
+ * This file implements the core of the height-balanced (AVL) tree management
+ * routines. The header file, ubi_AVLtree.h, contains function prototypes
+ * for all "exported" functions.
+ *
+ * -------------------------------------------------------------------------- **
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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 Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * -------------------------------------------------------------------------- **
+ *
+ * $Log: ubi_AVLtree.c,v $
+ * Revision 1.1 1997/10/09 04:09:51 crh
+ * This is my library of lists and trees. My hope is to replace all of the
+ * hard coded linked lists that are currently used in Samba with calls to
+ * these modules. This should make the code simpler, smaller, and (I hope)
+ * faster. The tree code, in particular, should speed up processing where
+ * large lists are involved.
+ *
+ * Chris -)-----
+ *
+ * Revision 2.4 1997/07/26 04:36:20 crh
+ * Andrew Leppard, aka "Grazgur", discovered that I still had my brains tied
+ * on backwards with respect to node deletion. I did some more digging and
+ * discovered that I was not changing the balance values correctly in the
+ * single rotation functions. Double rotation was working correctly because
+ * the formula for changing the balance values is the same for insertion or
+ * deletion. Not so for single rotation.
+ *
+ * I have tested the fix by loading the tree with over 44 thousand names,
+ * deleting 2,629 of them (all those in which the second character is 'u')
+ * and then walking the tree recursively to verify that the balance factor of
+ * each node is correct. Passed.
+ *
+ * Thanks Andrew!
+ *
+ * Also:
+ * + Changed ubi_TRUE and ubi_FALSE to ubi_trTRUE and ubi_trFALSE.
+ * + Rewrote the ubi_tr macros because they weren't doing what I'd
+ * hoped they would do (see the bottom of the header file). They work now.
+ *
+ * Revision 2.3 1997/06/03 04:41:35 crh
+ * Changed TRUE and FALSE to ubi_TRUE and ubi_FALSE to avoid causing
+ * problems.
+ *
+ * Revision 2.2 1995/10/03 22:16:01 CRH
+ * Ubisized!
+ *
+ * Revision 2.1 95/03/09 23:45:59 CRH
+ * Added the ModuleID static string and function. These modules are now
+ * self-identifying.
+ *
+ * Revision 2.0 95/03/05 14:10:51 CRH
+ * This revision of ubi_AVLtree coincides with revision 2.0 of ubi_BinTree,
+ * and so includes all of the changes to that module. In addition, a bug in
+ * the node deletion process has been fixed.
+ *
+ * After rewriting the Locate() function in ubi_BinTree, I decided that it was
+ * time to overhaul this module. In the process, I discovered a bug related
+ * to node deletion. To fix the bug, I wrote function Debalance(). A quick
+ * glance will show that it is very similar to the Rebalance() function. In
+ * previous versions of this module, I tried to include the functionality of
+ * Debalance() within Rebalance(), with poor results.
+ *
+ * Revision 1.0 93/10/15 22:58:56 CRH
+ * With this revision, I have added a set of #define's that provide a single,
+ * standard API to all existing tree modules. Until now, each of the three
+ * existing modules had a different function and typedef prefix, as follows:
+ *
+ * Module Prefix
+ * ubi_BinTree ubi_bt
+ * ubi_AVLtree ubi_avl
+ * ubi_SplayTree ubi_spt
+ *
+ * To further complicate matters, only those portions of the base module
+ * (ubi_BinTree) that were superceeded in the new module had the new names.
+ * For example, if you were using ubi_AVLtree, the AVL node structure was
+ * named "ubi_avlNode", but the root structure was still "ubi_btRoot". Using
+ * SplayTree, the locate function was called "ubi_sptLocate", but the next
+ * and previous functions remained "ubi_btNext" and "ubi_btPrev".
+ *
+ * This was not too terrible if you were familiar with the modules and knew
+ * exactly which tree model you wanted to use. If you wanted to be able to
+ * change modules (for speed comparisons, etc), things could get messy very
+ * quickly.
+ *
+ * So, I have added a set of defined names that get redefined in any of the
+ * descendant modules. To use this standardized interface in your code,
+ * simply replace all occurances of "ubi_bt", "ubi_avl", and "ubi_spt" with
+ * "ubi_tr". The "ubi_tr" names will resolve to the correct function or
+ * datatype names for the module that you are using. Just remember to
+ * include the header for that module in your program file. Because these
+ * names are handled by the preprocessor, there is no added run-time
+ * overhead.
+ *
+ * Note that the original names do still exist, and can be used if you wish
+ * to write code directly to a specific module. This should probably only be
+ * done if you are planning to implement a new descendant type, such as
+ * red/black trees. CRH
+ *
+ * V0.0 - May, 1990 - Written by Christopher R. Hertel (CRH).
+ *
+ * ========================================================================= **
+ */
+
+#include "ubi_AVLtree.h" /* Header for THIS module. */
+#include /* Standard C definitions, etc. */
+
+/* ========================================================================== **
+ * Static data.
+ */
+
+static char ModuleID[] = "ubi_AVLtree\n\
+\t$Revision: 1.1 $\n\
+\t$Date: 1997/10/09 04:09:51 $\n\
+\t$Author: crh $\n";
+
+/* ========================================================================== **
+ * The next set of functions are the AVL balancing routines. There are left
+ * and right, single and double rotations. The rotation routines handle the
+ * rotations and reconnect all tree pointers that might get confused by the
+ * rotations. A pointer to the new subtree root node is returned.
+ *
+ * Note that L1 and R1 are identical, except that all the RIGHTs and LEFTs
+ * are reversed. The same is true for L2 and R2. I'm sure that there is
+ * a clever way to reduce the amount of code by combining these functions,
+ * but it might involve additional overhead, and it would probably be a pain
+ * to read, debug, etc.
+ * -------------------------------------------------------------------------- **
+ */
+
+static ubi_avlNodePtr L1( ubi_avlNodePtr p )
+ /* ------------------------------------------------------------------------ **
+ * Single rotate left.
+ *
+ * Input: p - Pointer to the root of a tree (possibly a subtree).
+ * Output: A pointer to the new root of the same subtree (now that node
+ * p has been moved).
+ * ------------------------------------------------------------------------ **
+ */
+ {
+ ubi_avlNodePtr tmp;
+
+ tmp = p->Link[RIGHT];
+ p->Link[RIGHT] = tmp->Link[LEFT];
+ tmp->Link[LEFT] = p;
+
+ tmp->Link[PARENT] = p->Link[PARENT];
+ tmp->gender = p->gender;
+ if(tmp->Link[PARENT])
+ (tmp->Link[PARENT])->Link[(tmp->gender)] = tmp;
+ p->Link[PARENT] = tmp;
+ p->gender = LEFT;
+ if( p->Link[RIGHT] )
+ {
+ p->Link[RIGHT]->Link[PARENT] = p;
+ (p->Link[RIGHT])->gender = RIGHT;
+ }
+ p->balance -= Normalize( tmp->balance );
+ (tmp->balance)--;
+ return( tmp );
+ } /* L1 */
+
+static ubi_avlNodePtr R1( ubi_avlNodePtr p )
+ /* ------------------------------------------------------------------------ **
+ * Single rotate right.
+ *
+ * Input: p - Pointer to the root of a tree (possibly a subtree).
+ * Output: A pointer to the new root of the same subtree (now that node
+ * p has been moved).
+ * ------------------------------------------------------------------------ **
+ */
+ {
+ ubi_avlNodePtr tmp;
+
+ tmp = p->Link[LEFT];
+ p->Link[LEFT] = tmp->Link[RIGHT];
+ tmp->Link[RIGHT] = p;
+
+ tmp->Link[PARENT] = p->Link[PARENT];
+ tmp->gender = p->gender;
+ if(tmp->Link[PARENT])
+ (tmp->Link[PARENT])->Link[(tmp->gender)] = tmp;
+ p->Link[PARENT] = tmp;
+ p->gender = RIGHT;
+ if(p->Link[LEFT])
+ {
+ p->Link[LEFT]->Link[PARENT] = p;
+ p->Link[LEFT]->gender = LEFT;
+ }
+ p->balance -= Normalize( tmp->balance );
+ (tmp->balance)++;
+ return( tmp );
+ } /* R1 */
+
+static ubi_avlNodePtr L2( ubi_avlNodePtr tree )
+ /* ------------------------------------------------------------------------ **
+ * Double rotate left.
+ *
+ * Input: p - Pointer to the root of a tree (possibly a subtree).
+ * Output: A pointer to the new root of the same subtree (now that node
+ * p has been moved).
+ * ------------------------------------------------------------------------ **
+ */
+ {
+ ubi_avlNodePtr tmp, newroot;
+
+ tmp = tree->Link[RIGHT];
+ newroot = tmp->Link[LEFT];
+ tmp->Link[LEFT] = newroot->Link[RIGHT];
+ newroot->Link[RIGHT] = tmp;
+ tree->Link[RIGHT] = newroot->Link[LEFT];
+ newroot->Link[LEFT] = tree;
+
+ newroot->Link[PARENT] = tree->Link[PARENT];
+ newroot->gender = tree->gender;
+ tree->Link[PARENT] = newroot;
+ tree->gender = LEFT;
+ tmp->Link[PARENT] = newroot;
+ tmp->gender = RIGHT;
+
+ if( tree->Link[RIGHT] )
+ {
+ tree->Link[RIGHT]->Link[PARENT] = tree;
+ tree->Link[RIGHT]->gender = RIGHT;
+ }
+ if( tmp->Link[LEFT] )
+ {
+ tmp->Link[LEFT]->Link[PARENT] = tmp;
+ tmp->Link[LEFT]->gender = LEFT;
+ }
+ if(newroot->Link[PARENT])
+ newroot->Link[PARENT]->Link[newroot->gender] = newroot;
+
+ switch( newroot->balance )
+ {
+ case LEFT :
+ tree->balance = EQUAL; tmp->balance = RIGHT; break;
+ case EQUAL:
+ tree->balance = EQUAL; tmp->balance = EQUAL; break;
+ case RIGHT:
+ tree->balance = LEFT; tmp->balance = EQUAL; break;
+ }
+ newroot->balance = EQUAL;
+ return( newroot );
+ } /* L2 */
+
+static ubi_avlNodePtr R2( ubi_avlNodePtr tree )
+ /* ------------------------------------------------------------------------ **
+ * Double rotate right.
+ *
+ * Input: p - Pointer to the root of a tree (possibly a subtree).
+ * Output: A pointer to the new root of the same subtree (now that node
+ * p has been moved).
+ * ------------------------------------------------------------------------ **
+ */
+ {
+ ubi_avlNodePtr tmp, newroot;
+
+ tmp = tree->Link[LEFT];
+ newroot = tmp->Link[RIGHT];
+ tmp->Link[RIGHT] = newroot->Link[LEFT];
+ newroot->Link[LEFT] = tmp;
+ tree->Link[LEFT] = newroot->Link[RIGHT];
+ newroot->Link[RIGHT] = tree;
+
+ newroot->Link[PARENT] = tree->Link[PARENT];
+ newroot->gender = tree->gender;
+ tree->Link[PARENT] = newroot;
+ tree->gender = RIGHT;
+ tmp->Link[PARENT] = newroot;
+ tmp->gender = LEFT;
+
+ if( tree->Link[LEFT] )
+ {
+ tree->Link[LEFT]->Link[PARENT] = tree;
+ tree->Link[LEFT]->gender = LEFT;
+ }
+ if( tmp->Link[RIGHT] )
+ {
+ tmp->Link[RIGHT]->Link[PARENT] = tmp;
+ tmp->Link[RIGHT]->gender = RIGHT;
+ }
+ if(newroot->Link[PARENT])
+ newroot->Link[PARENT]->Link[newroot->gender] = newroot;
+
+ switch( newroot->balance )
+ {
+ case LEFT :
+ tree->balance = RIGHT; tmp->balance = EQUAL; break;
+ case EQUAL :
+ tree->balance = EQUAL; tmp->balance = EQUAL; break;
+ case RIGHT :
+ tree->balance = EQUAL; tmp->balance = LEFT; break;
+ }
+ newroot->balance = EQUAL;
+ return( newroot );
+ } /* R2 */
+
+
+static ubi_avlNodePtr Adjust( ubi_avlNodePtr p, char LorR )
+ /* ------------------------------------------------------------------------ **
+ * Adjust the balance value at node *p. If necessary, rotate the subtree
+ * rooted at p.
+ *
+ * Input: p - A pointer to the node to be adjusted. One of the
+ * subtrees of this node has changed height, so the
+ * balance value at this node must be adjusted, possibly
+ * by rotating the tree at this node.
+ * LorR - Indicates the TALLER subtree.
+ *
+ * Output: A pointer to the (possibly new) root node of the subtree.
+ *
+ * Notes: This function may be called after a node has been added *or*
+ * deleted, so LorR indicates the TALLER subtree.
+ * ------------------------------------------------------------------------ **
+ */
+ {
+ if( p->balance != LorR )
+ p->balance += Normalize(LorR);
+ else
+ {
+ char tallerbal; /* Balance value of the root of the taller subtree of p. */
+
+ tallerbal = p->Link[LorR]->balance;
+ if( ( EQUAL == tallerbal ) || ( p->balance == tallerbal ) )
+ p = ( (LEFT==LorR) ? R1(p) : L1(p) ); /* single rotation */
+ else
+ p = ( (LEFT==LorR) ? R2(p) : L2(p) ); /* double rotation */
+ }
+ return( p );
+ } /* Adjust */
+
+static ubi_avlNodePtr Rebalance( ubi_avlNodePtr Root,
+ ubi_avlNodePtr subtree,
+ char LorR )
+ /* ------------------------------------------------------------------------ **
+ * Rebalance the tree following an insertion.
+ *
+ * Input: Root - A pointer to the root node of the whole tree.
+ * subtree - A pointer to the node that has just gained a new
+ * child.
+ * LorR - Gender of the child that has just been gained.
+ *
+ * Output: A pointer to the (possibly new) root of the AVL tree.
+ * Rebalancing the tree moves nodes around a bit, so the node
+ * that *was* the root, may not be the root when we're finished.
+ *
+ * Notes: Rebalance() must walk up the tree from where we are (which is
+ * where the latest change occurred), rebalancing the subtrees
+ * along the way. The rebalancing operation can stop if the
+ * change at the current subtree root won't affect the rest of
+ * the tree. In the case of an addition, if a subtree root's
+ * balance becomes EQUAL, then we know that the height of that
+ * subtree has not changed, so we can exit.
+ * ------------------------------------------------------------------------ **
+ */
+ {
+ while( subtree )
+ {
+ subtree = Adjust( subtree, LorR );
+ if( PARENT == subtree->gender )
+ return( subtree );
+ if( EQUAL == subtree->balance )
+ return( Root );
+ LorR = subtree->gender;
+ subtree = subtree->Link[PARENT];
+ }
+ return( Root );
+ } /* Rebalance */
+
+static ubi_avlNodePtr Debalance( ubi_avlNodePtr Root,
+ ubi_avlNodePtr subtree,
+ char LorR )
+ /* ------------------------------------------------------------------------ **
+ * Rebalance the tree following a deletion.
+ *
+ * Input: Root - A pointer to the root node of the whole tree.
+ * subtree - A pointer to the node who's child has just "left the
+ * nest".
+ * LorR - Gender of the child that left.
+ *
+ * Output: A pointer to the (possibly new) root of the AVL tree.
+ * Rebalancing the tree moves nodes around a bit, so the node
+ * that *was* the root, may not be the root when we're finished.
+ *
+ * Notes: Debalance() is subtly different from Rebalance() (above) in
+ * two respects.
+ * * When it calls Adjust(), it passes the *opposite* of LorR.
+ * This is because LorR, as passed into Debalance() indicates
+ * the shorter subtree. As we move up the tree, LorR is
+ * assigned the gender of the node that we are leaving (i.e.,
+ * the subtree that we just rebalanced).
+ * * We know that a subtree has not changed height if the
+ * balance becomes LEFT or RIGHT. This is the *opposite* of
+ * what happens in Rebalance().
+ * ------------------------------------------------------------------------ **
+ */
+ {
+ while( subtree )
+ {
+ subtree = Adjust( subtree, RevWay(LorR) );
+ if( PARENT == subtree->gender )
+ return( subtree );
+ if( EQUAL != subtree->balance )
+ return( Root );
+ LorR = subtree->gender;
+ subtree = subtree->Link[PARENT];
+ }
+ return( Root );
+ } /* Debalance */
+
+
+/* -------------------------------------------------------------------------- **
+ * The next two functions are used for general tree manipulation. They are
+ * each slightly different from their ubi_BinTree counterparts.
+ * -------------------------------------------------------------------------- **
+ */
+
+static void ReplaceNode( ubi_avlNodePtr *parent,
+ ubi_avlNodePtr oldnode,
+ ubi_avlNodePtr newnode )
+ /* ------------------------------------------------------------------------ **
+ * Remove node oldnode from the tree, replacing it with node newnode.
+ *
+ * Input:
+ * parent - A pointer to he parent pointer of the node to be
+ * replaced. may point to the Link[] field of
+ * a parent node, or it may indicate the root pointer at
+ * the top of the tree.
+ * oldnode - A pointer to the node that is to be replaced.
+ * newnode - A pointer to the node that is to be installed in the
+ * place of <*oldnode>.
+ *
+ * Notes: Don't forget to free oldnode.
+ * The only difference between this function and the ubi_bt
+ * version is that the node size is sizeof( ubi_avlNode ), not
+ * sizeof( ubi_btNode ).
+ * ------------------------------------------------------------------------ **
+ */
+ {
+ register int i;
+ register int avlNodeSize = sizeof( ubi_avlNode );
+
+ for( i = 0; i < avlNodeSize; i++ )
+ ((unsigned char *)newnode)[i] = ((unsigned char *)oldnode)[i];
+ (*parent) = newnode;
+
+ if(oldnode->Link[LEFT ] )
+ (oldnode->Link[LEFT ])->Link[PARENT] = newnode;
+ if(oldnode->Link[RIGHT] )
+ (oldnode->Link[RIGHT])->Link[PARENT] = newnode;
+ } /* ReplaceNode */
+
+static void SwapNodes( ubi_btRootPtr RootPtr,
+ ubi_avlNodePtr Node1,
+ ubi_avlNodePtr Node2 )
+ /* ------------------------------------------------------------------------ **
+ * This function swaps two nodes in the tree. Node1 will take the place of
+ * Node2, and Node2 will fill in the space left vacant by Node 1.
+ *
+ * Input:
+ * RootPtr - pointer to the tree header structure for this tree.
+ * Node1 - \
+ * > These are the two nodes which are to be swapped.
+ * Node2 - /
+ *
+ * Notes:
+ * This function does a three step swap, using a dummy node as a place
+ * holder. This function is used by ubi_avlRemove().
+ * The only difference between this function and its ubi_bt counterpart
+ * is that the nodes are ubi_avlNodes, not ubi_btNodes.
+ * ------------------------------------------------------------------------ **
+ */
+ {
+ ubi_avlNodePtr *Parent;
+ ubi_avlNode dummy;
+ ubi_avlNodePtr dummy_p = &dummy;
+
+ if( Node1->Link[PARENT] )
+ Parent = &((Node1->Link[PARENT])->Link[Node1->gender]);
+ else
+ Parent = (ubi_avlNodePtr *)&(RootPtr->root);
+ ReplaceNode( Parent, Node1, dummy_p );
+
+ if( Node2->Link[PARENT] )
+ Parent = &((Node2->Link[PARENT])->Link[Node2->gender]);
+ else
+ Parent = (ubi_avlNodePtr *)&(RootPtr->root);
+ ReplaceNode( Parent, Node2, Node1 );
+
+ if( dummy_p->Link[PARENT] )
+ Parent = &((dummy_p->Link[PARENT])->Link[dummy_p->gender]);
+ else
+ Parent = (ubi_avlNodePtr *)&(RootPtr->root);
+ ReplaceNode( Parent, dummy_p, Node2 );
+ } /* SwapNodes */
+
+
+/* ========================================================================== **
+ * Public, exported (ie. not static-ly declared) functions...
+ * -------------------------------------------------------------------------- **
+ */
+
+ubi_avlNodePtr ubi_avlInitNode( ubi_avlNodePtr NodePtr )
+ /* ------------------------------------------------------------------------ **
+ * Initialize a tree node.
+ *
+ * Input: NodePtr - pointer to a ubi_btNode structure to be
+ * initialized.
+ * Output: a pointer to the initialized ubi_avlNode structure (ie. the
+ * same as the input pointer).
+ * ------------------------------------------------------------------------ **
+ */
+ {
+ (void)ubi_btInitNode( (ubi_btNodePtr)NodePtr );
+ NodePtr->balance = EQUAL;
+ return( NodePtr );
+ } /* ubi_avlInitNode */
+
+ubi_trBool ubi_avlInsert( ubi_btRootPtr RootPtr,
+ ubi_avlNodePtr NewNode,
+ ubi_btItemPtr ItemPtr,
+ ubi_avlNodePtr *OldNode )
+ /* ------------------------------------------------------------------------ **
+ * This function uses a non-recursive algorithm to add a new element to
+ * the tree.
+ *
+ * Input: RootPtr - a pointer to the ubi_btRoot structure that indicates
+ * the root of the tree to which NewNode is to be added.
+ * NewNode - a pointer to an ubi_avlNode structure that is NOT
+ * part of any tree.
+ * ItemPtr - A pointer to the sort key that is stored within
+ * *NewNode. ItemPtr MUST point to information stored
+ * in *NewNode or an EXACT DUPLICATE. The key data
+ * indicated by ItemPtr is used to place the new node
+ * into the tree.
+ * OldNode - a pointer to an ubi_btNodePtr. When searching
+ * the tree, a duplicate node may be found. If
+ * duplicates are allowed, then the new node will
+ * be simply placed into the tree. If duplicates
+ * are not allowed, however, then one of two things
+ * may happen.
+ * 1) if overwritting *is not* allowed, this
+ * function will return FALSE (indicating that
+ * the new node could not be inserted), and
+ * *OldNode will point to the duplicate that is
+ * still in the tree.
+ * 2) if overwritting *is* allowed, then this
+ * function will swap **OldNode for *NewNode.
+ * In this case, *OldNode will point to the node
+ * that was removed (thus allowing you to free
+ * the node).
+ * ** If you are using overwrite mode, ALWAYS **
+ * ** check the return value of this parameter! **
+ * Note: You may pass NULL in this parameter, the
+ * function knows how to cope. If you do this,
+ * however, there will be no way to return a
+ * pointer to an old (ie. replaced) node (which is
+ * a problem if you are using overwrite mode).
+ *
+ * Output: a boolean value indicating success or failure. The function
+ * will return FALSE if the node could not be added to the tree.
+ * Such failure will only occur if duplicates are not allowed,
+ * nodes cannot be overwritten, AND a duplicate key was found
+ * within the tree.
+ * ------------------------------------------------------------------------ **
+ */
+ {
+ ubi_avlNodePtr OtherP;
+
+ if( !(OldNode) ) OldNode = &OtherP;
+ if( ubi_btInsert( RootPtr,
+ (ubi_btNodePtr)NewNode,
+ ItemPtr,
+ (ubi_btNodePtr *)OldNode ) )
+ {
+ if( (*OldNode) )
+ NewNode->balance = (*OldNode)->balance;
+ else
+ {
+ NewNode->balance = EQUAL;
+ RootPtr->root = (ubi_btNodePtr)Rebalance( (ubi_avlNodePtr)RootPtr->root,
+ NewNode->Link[PARENT],
+ NewNode->gender );
+ }
+ return( ubi_trTRUE );
+ }
+ return( ubi_trFALSE ); /* Failure: could not replace an existing node. */
+ } /* ubi_avlInsert */
+
+ubi_avlNodePtr ubi_avlRemove( ubi_btRootPtr RootPtr,
+ ubi_avlNodePtr DeadNode )
+ /* ------------------------------------------------------------------------ **
+ * This function removes the indicated node from the tree, after which the
+ * tree is rebalanced.
+ *
+ * Input: RootPtr - A pointer to the header of the tree that contains
+ * the node to be removed.
+ * DeadNode - A pointer to the node that will be removed.
+ *
+ * Output: This function returns a pointer to the node that was removed
+ * from the tree (ie. the same as DeadNode).
+ *
+ * Note: The node MUST be in the tree indicated by RootPtr. If not,
+ * strange and evil things will happen to your trees.
+ * ------------------------------------------------------------------------ **
+ */
+ {
+ ubi_btNodePtr p,
+ *parentp;
+
+ /* if the node has both left and right subtrees, then we have to swap
+ * it with another node.
+ */
+ if( (DeadNode->Link[LEFT]) && (DeadNode->Link[RIGHT]) )
+ SwapNodes( RootPtr, DeadNode, ubi_trPrev( DeadNode ) );
+
+ /* The parent of the node to be deleted may be another node, or it may be
+ * the root of the tree. Since we're not sure, it's best just to have
+ * a pointer to the parent pointer, whatever it is.
+ */
+ if( DeadNode->Link[PARENT] )
+ parentp = (ubi_btNodePtr *)
+ &((DeadNode->Link[PARENT])->Link[(DeadNode->gender)]);
+ else
+ parentp = &( RootPtr->root );
+
+ /* Now link the parent to the only grand-child. Patch up the gender and
+ * such, and rebalance.
+ */
+ if( EQUAL == DeadNode->balance )
+ (*parentp) = NULL;
+ else
+ {
+ p = (ubi_btNodePtr)(DeadNode->Link[(DeadNode->balance)]);
+ p->Link[PARENT] = (ubi_btNodePtr)DeadNode->Link[PARENT];
+ p->gender = DeadNode->gender;
+ (*parentp) = p;
+ }
+ RootPtr->root = (ubi_btNodePtr)Debalance( (ubi_avlNodePtr)RootPtr->root,
+ DeadNode->Link[PARENT],
+ DeadNode->gender );
+
+ (RootPtr->count)--;
+ return( DeadNode );
+ } /* ubi_avlRemove */
+
+int ubi_avlModuleID( int size, char *list[] )
+ /* ------------------------------------------------------------------------ **
+ * Returns a set of strings that identify the module.
+ *
+ * Input: size - The number of elements in the array .
+ * list - An array of pointers of type (char *). This array
+ * should, initially, be empty. This function will fill
+ * in the array with pointers to strings.
+ * Output: The number of elements of that were used. If this value
+ * is less than , the values of the remaining elements are
+ * not guaranteed.
+ *
+ * Notes: Please keep in mind that the pointers returned indicate strings
+ * stored in static memory. Don't free() them, don't write over
+ * them, etc. Just read them.
+ * ------------------------------------------------------------------------ **
+ */
+ {
+ if( size > 0 )
+ {
+ list[0] = ModuleID;
+ if( size > 1 )
+ return( 1 + ubi_btModuleID( --size, &(list[1]) ) );
+ return( 1 );
+ }
+ return( 0 );
+ } /* ubi_avlModuleID */
+
+/* ============================== The End ============================== */
diff --git a/source/ubi_AVLtree.h b/source/ubi_AVLtree.h
new file mode 100644
index 00000000000..27d84a2896d
--- /dev/null
+++ b/source/ubi_AVLtree.h
@@ -0,0 +1,340 @@
+#ifndef ubi_AVLtree_H
+#define ubi_AVLtree_H
+/* ========================================================================== **
+ * ubi_AVLtree.h
+ *
+ * Copyright (C) 1991-1997 by Christopher R. Hertel
+ *
+ * Email: crh@ubiqx.mn.org
+ * -------------------------------------------------------------------------- **
+ *
+ * This module provides an implementation of AVL height balanced binary
+ * trees. (Adelson-Velskii, Landis 1962)
+ *
+ * This header file contains the basic AVL structure and pointer typedefs
+ * as well as the prototypes needed to access the functions in the AVL
+ * module ubi_AVLtree. The .c file implements the low-level height balancing
+ * routines that manage the AVL tree, plus all of the basic primops for
+ * adding, searching for, and deleting nodes.
+ *
+ * -------------------------------------------------------------------------- **
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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 Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * -------------------------------------------------------------------------- **
+ * $Log: ubi_AVLtree.h,v $
+ * Revision 1.1 1997/10/09 04:09:51 crh
+ * This is my library of lists and trees. My hope is to replace all of the
+ * hard coded linked lists that are currently used in Samba with calls to
+ * these modules. This should make the code simpler, smaller, and (I hope)
+ * faster. The tree code, in particular, should speed up processing where
+ * large lists are involved.
+ *
+ * Chris -)-----
+ *
+ * Revision 2.4 1997/07/26 04:36:23 crh
+ * Andrew Leppard, aka "Grazgur", discovered that I still had my brains tied
+ * on backwards with respect to node deletion. I did some more digging and
+ * discovered that I was not changing the balance values correctly in the
+ * single rotation functions. Double rotation was working correctly because
+ * the formula for changing the balance values is the same for insertion or
+ * deletion. Not so for single rotation.
+ *
+ * I have tested the fix by loading the tree with over 44 thousand names,
+ * deleting 2,629 of them (all those in which the second character is 'u')
+ * and then walking the tree recursively to verify that the balance factor of
+ * each node is correct. Passed.
+ *
+ * Thanks Andrew!
+ *
+ * Also:
+ * + Changed ubi_TRUE and ubi_FALSE to ubi_trTRUE and ubi_trFALSE.
+ * + Rewrote the ubi_tr macros because they weren't doing what I'd
+ * hoped they would do (see the bottom of the header file). They work now.
+ *
+ * Revision 2.3 1997/06/03 05:22:07 crh
+ * Changed TRUE and FALSE to ubi_TRUE and ubi_FALSE to avoid causing
+ * problems.
+ *
+ * Revision 2.2 1995/10/03 22:15:47 CRH
+ * Ubisized!
+ *
+ * Revision 2.1 95/03/09 23:46:44 CRH
+ * Added the ModuleID static string and function. These modules are now
+ * self-identifying.
+ *
+ * Revision 2.0 95/03/05 14:11:22 CRH
+ * This revision of ubi_AVLtree coincides with revision 2.0 of ubi_BinTree,
+ * and so includes all of the changes to that module. In addition, a bug in
+ * the node deletion process has been fixed.
+ *
+ * After rewriting the Locate() function in ubi_BinTree, I decided that it was
+ * time to overhaul this module. In the process, I discovered a bug related
+ * to node deletion. To fix the bug, I wrote function Debalance(). A quick
+ * glance will show that it is very similar to the Rebalance() function. In
+ * previous versions of this module, I tried to include the functionality of
+ * Debalance() within Rebalance(), with poor results.
+ *
+ * Revision 1.0 93/10/15 22:58:48 CRH
+ * With this revision, I have added a set of #define's that provide a single,
+ * standard API to all existing tree modules. Until now, each of the three
+ * existing modules had a different function and typedef prefix, as follows:
+ *
+ * Module Prefix
+ * ubi_BinTree ubi_bt
+ * ubi_AVLtree ubi_avl
+ * ubi_SplayTree ubi_spt
+ *
+ * To further complicate matters, only those portions of the base module
+ * (ubi_BinTree) that were superceeded in the new module had the new names.
+ * For example, if you were using ubi_AVLtree, the AVL node structure was
+ * named "ubi_avlNode", but the root structure was still "ubi_btRoot". Using
+ * SplayTree, the locate function was called "ubi_sptLocate", but the next
+ * and previous functions remained "ubi_btNext" and "ubi_btPrev".
+ *
+ * This was not too terrible if you were familiar with the modules and knew
+ * exactly which tree model you wanted to use. If you wanted to be able to
+ * change modules (for speed comparisons, etc), things could get messy very
+ * quickly.
+ *
+ * So, I have added a set of defined names that get redefined in any of the
+ * descendant modules. To use this standardized interface in your code,
+ * simply replace all occurances of "ubi_bt", "ubi_avl", and "ubi_spt" with
+ * "ubi_tr". The "ubi_tr" names will resolve to the correct function or
+ * datatype names for the module that you are using. Just remember to
+ * include the header for that module in your program file. Because these
+ * names are handled by the preprocessor, there is no added run-time
+ * overhead.
+ *
+ * Note that the original names do still exist, and can be used if you wish
+ * to write code directly to a specific module. This should probably only be
+ * done if you are planning to implement a new descendant type, such as
+ * red/black trees. CRH
+ *
+ * V0.0 - May, 1990 - Written by Christopher R. Hertel (CRH).
+ *
+ * ========================================================================= **
+ */
+
+#include "ubi_BinTree.h" /* Base erg binary tree support. */
+
+/* ------------------------------------------------------------------------- **
+ * AVL Tree Node Structure: This structure defines the basic elements of
+ * the AVL tree nodes. In general you *SHOULD NOT PLAY WITH THESE
+ * FIELDS*! But, of course, I have to put the structure into this
+ * header so that you can use the structure as a building block.
+ *
+ * The fields are as follows:
+ * Link - An array of pointers. These pointers are manipulated by the
+ * BT and AVL routines, and indicate the left and right child
+ * nodes, plus the parent node. By keeping track of the parent
+ * pointer, we avoid the need for recursive routines or hand-
+ * tooled stacks to keep track of our path back to the root.
+ * The use of these pointers is subject to change without
+ * notice.
+ * gender - For tree rebalancing purposes, it is necessary that each node
+ * know whether it is the left or right child of its parent, or
+ * if it is the root. This information is stored in this field.
+ * balance - This field is also needed for AVL balancing purposes. It
+ * indicates which subtree of the current node is longer, or if
+ * the subtrees are, in fact, balanced with respect to each
+ * other.
+ * ------------------------------------------------------------------------- **
+ */
+
+typedef struct ubi_avlNodeStruct {
+ struct ubi_avlNodeStruct
+ *Link[3]; /* Normal Binary Tree Node type. */
+ char gender; /* The node is either the RIGHT or LEFT child of its */
+ /* parent, or is the root node. */
+ char balance; /* In an AVL tree, each node is the root of a subtree */
+ /* that may be balanced, or be one node longer to the */
+ /* right or left. This field keeps track of the */
+ /* balance value of each node. */
+ } ubi_avlNode; /* Typedef'd name for an avl tree node. */
+
+typedef ubi_avlNode *ubi_avlNodePtr; /* a Pointer to an AVL node */
+
+/* -------------------------------------------------------------------------- **
+ * Function prototypes.
+ * -------------------------------------------------------------------------- **
+ */
+
+ubi_avlNodePtr ubi_avlInitNode( ubi_avlNodePtr NodePtr );
+ /* ------------------------------------------------------------------------ **
+ * Initialize a tree node.
+ *
+ * Input: NodePtr - a pointer to a ubi_btNode structure to be
+ * initialized.
+ * Output: a pointer to the initialized ubi_avlNode structure (ie. the
+ * same as the input pointer).
+ * ------------------------------------------------------------------------ **
+ */
+
+ubi_trBool ubi_avlInsert( ubi_btRootPtr RootPtr,
+ ubi_avlNodePtr NewNode,
+ ubi_btItemPtr ItemPtr,
+ ubi_avlNodePtr *OldNode );
+ /* ------------------------------------------------------------------------ **
+ * This function uses a non-recursive algorithm to add a new element to
+ * the tree.
+ *
+ * Input: RootPtr - a pointer to the ubi_btRoot structure that indicates
+ * the root of the tree to which NewNode is to be added.
+ * NewNode - a pointer to an ubi_avlNode structure that is NOT
+ * part of any tree.
+ * ItemPtr - A pointer to the sort key that is stored within
+ * *NewNode. ItemPtr MUST point to information stored
+ * in *NewNode or an EXACT DUPLICATE. The key data
+ * indicated by ItemPtr is used to place the new node
+ * into the tree.
+ * OldNode - a pointer to an ubi_btNodePtr. When searching
+ * the tree, a duplicate node may be found. If
+ * duplicates are allowed, then the new node will
+ * be simply placed into the tree. If duplicates
+ * are not allowed, however, then one of two things
+ * may happen.
+ * 1) if overwritting *is not* allowed, this
+ * function will return FALSE (indicating that
+ * the new node could not be inserted), and
+ * *OldNode will point to the duplicate that is
+ * still in the tree.
+ * 2) if overwritting *is* allowed, then this
+ * function will swap **OldNode for *NewNode.
+ * In this case, *OldNode will point to the node
+ * that was removed (thus allowing you to free
+ * the node).
+ * ** If you are using overwrite mode, ALWAYS **
+ * ** check the return value of this parameter! **
+ * Note: You may pass NULL in this parameter, the
+ * function knows how to cope. If you do this,
+ * however, there will be no way to return a
+ * pointer to an old (ie. replaced) node (which is
+ * a problem if you are using overwrite mode).
+ *
+ * Output: a boolean value indicating success or failure. The function
+ * will return FALSE if the node could not be added to the tree.
+ * Such failure will only occur if duplicates are not allowed,
+ * nodes cannot be overwritten, AND a duplicate key was found
+ * within the tree.
+ * ------------------------------------------------------------------------ **
+ */
+
+ubi_avlNodePtr ubi_avlRemove( ubi_btRootPtr RootPtr,
+ ubi_avlNodePtr DeadNode );
+ /* ------------------------------------------------------------------------ **
+ * This function removes the indicated node from the tree, after which the
+ * tree is rebalanced.
+ *
+ * Input: RootPtr - A pointer to the header of the tree that contains
+ * the node to be removed.
+ * DeadNode - A pointer to the node that will be removed.
+ *
+ * Output: This function returns a pointer to the node that was removed
+ * from the tree (ie. the same as DeadNode).
+ *
+ * Note: The node MUST be in the tree indicated by RootPtr. If not,
+ * strange and evil things will happen to your trees.
+ * ------------------------------------------------------------------------ **
+ */
+
+int ubi_avlModuleID( int size, char *list[] );
+ /* ------------------------------------------------------------------------ **
+ * Returns a set of strings that identify the module.
+ *
+ * Input: size - The number of elements in the array .
+ * list - An array of pointers of type (char *). This array
+ * should, initially, be empty. This function will fill
+ * in the array with pointers to strings.
+ * Output: The number of elements of that were used. If this value
+ * is less than , the values of the remaining elements are
+ * not guaranteed.
+ *
+ * Notes: Please keep in mind that the pointers returned indicate strings
+ * stored in static memory. Don't free() them, don't write over
+ * them, etc. Just read them.
+ * ------------------------------------------------------------------------ **
+ */
+
+/* -------------------------------------------------------------------------- **
+ * Masquarade...
+ *
+ * This set of defines allows you to write programs that will use any of the
+ * implemented binary tree modules (currently BinTree, AVLtree, and SplayTree).
+ * Instead of using ubi_avl... or ubi_bt, use ubi_tr... and select the tree
+ * type by including the appropriate module header.
+ */
+
+#undef ubi_trNode
+#undef ubi_trNodePtr
+#define ubi_trNode ubi_avlNode
+#define ubi_trNodePtr ubi_avlNodePtr
+
+#undef ubi_trInitNode
+#define ubi_trInitNode( Np ) ubi_avlInitNode( (ubi_avlNodePtr)(Np) )
+
+#undef ubi_trInsert
+#define ubi_trInsert( Rp, Nn, Ip, On ) \
+ ubi_avlInsert( (ubi_btRootPtr)(Rp), (ubi_avlNodePtr)(Nn), \
+ (ubi_btItemPtr)(Ip), (ubi_avlNodePtr *)(On) )
+
+#undef ubi_trRemove
+#define ubi_trRemove( Rp, Dn ) \
+ ubi_avlRemove( (ubi_btRootPtr)(Rp), (ubi_avlNodePtr)(Dn) )
+
+#undef ubi_trLocate
+#define ubi_trLocate( Rp, Ip, Op ) \
+ (ubi_avlNodePtr)ubi_btLocate( (ubi_btRootPtr)(Rp), \
+ (ubi_btItemPtr)(Ip), \
+ (ubi_trCompOps)(Op) )
+
+#undef ubi_trFind
+#define ubi_trFind( Rp, Ip ) \
+ (ubi_avlNodePtr)ubi_btFind( (ubi_btRootPtr)(Rp), (ubi_btItemPtr)(Ip) )
+
+#undef ubi_trNext
+#define ubi_trNext( P ) (ubi_avlNodePtr)ubi_btNext( (ubi_btNodePtr)(P) )
+
+#undef ubi_trPrev
+#define ubi_trPrev( P ) (ubi_avlNodePtr)ubi_btPrev( (ubi_btNodePtr)(P) )
+
+#undef ubi_trFirst
+#define ubi_trFirst( P ) (ubi_avlNodePtr)ubi_btFirst( (ubi_btNodePtr)(P) )
+
+#undef ubi_trLast
+#define ubi_trLast( P ) (ubi_avlNodePtr)ubi_btLast( (ubi_btNodePtr)(P) )
+
+#undef ubi_trFirstOf
+#define ubi_trFirstOf( Rp, Ip, P ) \
+ (ubi_avlNodePtr)ubi_btFirstOf( (ubi_btRootPtr)(Rp), \
+ (ubi_btItemPtr)(Ip), \
+ (ubi_btNodePtr)(P) )
+
+#undef ubi_trLastOf
+#define ubi_trLastOf( Rp, Ip, P ) \
+ (ubi_avlNodePtr)ubi_btLastOf( (ubi_btRootPtr)(Rp), \
+ (ubi_btItemPtr)(Ip), \
+ (ubi_btNodePtr)(P) )
+
+#undef ubi_trLeafNode
+#define ubi_trLeafNode( Nd ) \
+ (ubi_avlNodePtr)ubi_btLeafNode( (ubi_btNodePtr)(Nd) )
+
+#undef ubi_trModuleID
+#define ubi_trModuleID( s, l ) ubi_avlModuleID( s, l )
+
+
+/* =========================== End ubi_AVLtree.h =========================== */
+#endif /* ubi_AVLtree_H */
diff --git a/source/ubi_BinTree.c b/source/ubi_BinTree.c
new file mode 100644
index 00000000000..e6db1a4816c
--- /dev/null
+++ b/source/ubi_BinTree.c
@@ -0,0 +1,1042 @@
+/* ========================================================================== **
+ * ubi_BinTree.c
+ *
+ * Copyright (C) 1991-1997 by Christopher R. Hertel
+ *
+ * Email: crh@ubiqx.mn.org
+ * -------------------------------------------------------------------------- **
+ *
+ * ubi_BinTree manages a simple binary tree. Nothing fancy here. No height
+ * balancing, no restructuring. Still, a good tool for creating short, low-
+ * overhead sorted lists of things that need to be found in a hurry.
+ *
+ * In addition, this module provides a good basis for creating other types
+ * of binary tree handling modules.
+ *
+ * -------------------------------------------------------------------------- **
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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 Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * -------------------------------------------------------------------------- **
+ *
+ * $Log: ubi_BinTree.c,v $
+ * Revision 1.1 1997/10/09 04:09:52 crh
+ * This is my library of lists and trees. My hope is to replace all of the
+ * hard coded linked lists that are currently used in Samba with calls to
+ * these modules. This should make the code simpler, smaller, and (I hope)
+ * faster. The tree code, in particular, should speed up processing where
+ * large lists are involved.
+ *
+ * Chris -)-----
+ *
+ * Revision 2.4 1997/07/26 04:11:10 crh
+ * + Just to be annoying I changed ubi_TRUE and ubi_FALSE to ubi_trTRUE
+ * and ubi_trFALSE.
+ * + There is now a type ubi_trBool to go with ubi_trTRUE and ubi_trFALSE.
+ * + There used to be something called "ubi_TypeDefs.h". I got rid of it.
+ * + Added function ubi_btLeafNode().
+ *
+ * Revision 2.3 1997/06/03 05:16:17 crh
+ * Changed TRUE and FALSE to ubi_TRUE and ubi_FALSE to avoid conflicts.
+ * Also changed the interface to function InitTree(). See the comments
+ * for this function for more information.
+ *
+ * Revision 2.2 1995/10/03 22:00:07 CRH
+ * Ubisized!
+ *
+ * Revision 2.1 95/03/09 23:37:10 CRH
+ * Added the ModuleID static string and function. These modules are now
+ * self-identifying.
+ *
+ * Revision 2.0 95/02/27 22:00:17 CRH
+ * Revision 2.0 of this program includes the following changes:
+ *
+ * 1) A fix to a major typo in the RepaceNode() function.
+ * 2) The addition of the static function Border().
+ * 3) The addition of the public functions FirstOf() and LastOf(), which
+ * use Border(). These functions are used with trees that allow
+ * duplicate keys.
+ * 4) A complete rewrite of the Locate() function. Locate() now accepts
+ * a "comparison" operator.
+ * 5) Overall enhancements to both code and comments.
+ *
+ * I decided to give this a new major rev number because the interface has
+ * changed. In particular, there are two new functions, and changes to the
+ * Locate() function.
+ *
+ * Revision 1.0 93/10/15 22:44:59 CRH
+ * With this revision, I have added a set of #define's that provide a single,
+ * standard API to all existing tree modules. Until now, each of the three
+ * existing modules had a different function and typedef prefix, as follows:
+ *
+ * Module Prefix
+ * ubi_BinTree ubi_bt
+ * ubi_AVLtree ubi_avl
+ * ubi_SplayTree ubi_spt
+ *
+ * To further complicate matters, only those portions of the base module
+ * (ubi_BinTree) that were superceeded in the new module had the new names.
+ * For example, if you were using ubi_AVLtree, the AVL node structure was
+ * named "ubi_avlNode", but the root structure was still "ubi_btRoot". Using
+ * SplayTree, the locate function was called "ubi_sptLocate", but the next
+ * and previous functions remained "ubi_btNext" and "ubi_btPrev".
+ *
+ * This was not too terrible if you were familiar with the modules and knew
+ * exactly which tree model you wanted to use. If you wanted to be able to
+ * change modules (for speed comparisons, etc), things could get messy very
+ * quickly.
+ *
+ * So, I have added a set of defined names that get redefined in any of the
+ * descendant modules. To use this standardized interface in your code,
+ * simply replace all occurances of "ubi_bt", "ubi_avl", and "ubi_spt" with
+ * "ubi_tr". The "ubi_tr" names will resolve to the correct function or
+ * datatype names for the module that you are using. Just remember to
+ * include the header for that module in your program file. Because these
+ * names are handled by the preprocessor, there is no added run-time
+ * overhead.
+ *
+ * Note that the original names do still exist, and can be used if you wish
+ * to write code directly to a specific module. This should probably only be
+ * done if you are planning to implement a new descendant type, such as
+ * red/black trees. CRH
+ *
+ * V0.0 - June, 1991 - Written by Christopher R. Hertel (CRH).
+ *
+ * ========================================================================== **
+ */
+
+#include "ubi_BinTree.h" /* Header for this module */
+#include /* Standard C definitions. */
+
+/* ========================================================================== **
+ * Static data.
+ */
+
+static char ModuleID[] = "ubi_BinTree\n\
+\t$Revision: 1.1 $\n\
+\t$Date: 1997/10/09 04:09:52 $\n\
+\t$Author: crh $\n";
+
+/* ========================================================================== **
+ * Internal (private) functions.
+ */
+
+static ubi_btNodePtr qFind( ubi_btCompFunc cmp,
+ ubi_btItemPtr FindMe,
+ register ubi_btNodePtr p )
+ /* ------------------------------------------------------------------------ **
+ * This function performs a non-recursive search of a tree for a node
+ * matching a specific key. It is called "qFind()" because it is
+ * faster that TreeFind (below).
+ *
+ * Input:
+ * cmp - a pointer to the tree's comparison function.
+ * FindMe - a pointer to the key value for which to search.
+ * p - a pointer to the starting point of the search.
+ * is considered to be the root of a subtree, and only
+ * the subtree will be searched.
+ *
+ * Output:
+ * A pointer to a node with a key that matches the key indicated by
+ * FindMe, or NULL if no such node was found.
+ *
+ * Note: In a tree that allows duplicates, the pointer returned *might
+ * not* point to the (sequentially) first occurance of the
+ * desired key.
+ * ------------------------------------------------------------------------ **
+ */
+ {
+ char tmp;
+
+ while( p && (( tmp = AbNormal((*cmp)(FindMe, p)) ) != EQUAL) )
+ p = p->Link[tmp];
+
+ return( p );
+ } /* qFind */
+
+static ubi_btNodePtr TreeFind( ubi_btItemPtr findme,
+ ubi_btNodePtr p,
+ ubi_btNodePtr *parentp,
+ char *gender,
+ ubi_btCompFunc CmpFunc )
+ /* ------------------------------------------------------------------------ **
+ * TreeFind() searches a tree for a given value (findme). It will return a
+ * pointer to the target node, if found, or NULL if the target node was not
+ * found.
+ *
+ * TreeFind() also returns, via parameters, a pointer to the parent of the
+ * target node, and a LEFT or RIGHT value indicating which child of the
+ * parent is the target node. *If the target is not found*, then these
+ * values indicate the place at which the target *should be found*. This
+ * is useful when inserting a new node into a tree or searching for nodes
+ * "near" the target node.
+ *
+ * The parameters are:
+ *
+ * findme - is a pointer to the key information to be searched for.
+ * p - points to the root of the tree to be searched.
+ * parentp - will return a pointer to a pointer to the !parent! of the
+ * target node, which can be especially usefull if the target
+ * was not found.
+ * gender - returns LEFT or RIGHT to indicate which child of *parentp
+ * was last searched.
+ * CmpFunc - points to the comparison function.
+ *
+ * This function is called by ubi_btLocate() and ubi_btInsert().
+ * ------------------------------------------------------------------------ **
+ */
+ {
+ register ubi_btNodePtr tmp_p = p;
+ ubi_btNodePtr tmp_pp = NULL;
+ char tmp_sex = EQUAL;
+ char tmp_cmp;
+
+ while( tmp_p && (EQUAL != (tmp_cmp = AbNormal((*CmpFunc)(findme, tmp_p)))) )
+ {
+ tmp_pp = tmp_p; /* Keep track of previous node. */
+ tmp_sex = tmp_cmp; /* Keep track of sex of child. */
+ tmp_p = tmp_p->Link[tmp_cmp]; /* Go to child. */
+ }
+ *parentp = tmp_pp; /* Return results. */
+ *gender = tmp_sex;
+ return( tmp_p );
+ } /* TreeFind */
+
+static void ReplaceNode( ubi_btNodePtr *parent,
+ ubi_btNodePtr oldnode,
+ ubi_btNodePtr newnode )
+ /* ------------------------------------------------------------------ *
+ * Remove node oldnode from the tree, replacing it with node newnode.
+ *
+ * Input:
+ * parent - A pointer to he parent pointer of the node to be
+ * replaced. may point to the Link[] field of
+ * a parent node, or it may indicate the root pointer at
+ * the top of the tree.
+ * oldnode - A pointer to the node that is to be replaced.
+ * newnode - A pointer to the node that is to be installed in the
+ * place of <*oldnode>.
+ *
+ * Notes: Don't forget to free oldnode.
+ * Also, this function used to have a really nasty typo
+ * bug. "oldnode" and "newnode" were swapped in the line
+ * that now reads:
+ * ((unsigned char *)newnode)[i] = ((unsigned char *)oldnode)[i];
+ * Bleah!
+ * ------------------------------------------------------------------ *
+ */
+ {
+ register int i;
+ register int btNodeSize = sizeof( ubi_btNode );
+
+ for( i = 0; i < btNodeSize; i++ ) /* Copy node internals to new node. */
+ ((unsigned char *)newnode)[i] = ((unsigned char *)oldnode)[i];
+ (*parent) = newnode; /* Old node's parent points to new child. */
+ /* Now tell the children about their new step-parent. */
+ if( oldnode->Link[LEFT ] ) (oldnode->Link[LEFT ])->Link[PARENT] = newnode;
+ if( oldnode->Link[RIGHT] ) (oldnode->Link[RIGHT])->Link[PARENT] = newnode;
+ } /* ReplaceNode */
+
+static void SwapNodes( ubi_btRootPtr RootPtr,
+ ubi_btNodePtr Node1,
+ ubi_btNodePtr Node2 )
+ /* ------------------------------------------------------------------------ **
+ * This function swaps two nodes in the tree. Node1 will take the place of
+ * Node2, and Node2 will fill in the space left vacant by Node 1.
+ *
+ * Input:
+ * RootPtr - pointer to the tree header structure for this tree.
+ * Node1 - \
+ * > These are the two nodes which are to be swapped.
+ * Node2 - /
+ *
+ * Notes:
+ * This function does a three step swap, using a dummy node as a place
+ * holder. This function is used by ubi_btRemove().
+ * ------------------------------------------------------------------------ **
+ */
+ {
+ ubi_btNodePtr *Parent;
+ ubi_btNode dummy;
+ ubi_btNodePtr dummy_p = &dummy;
+
+ /* Replace Node 1 with the dummy, thus removing Node1 from the tree. */
+ if( Node1->Link[PARENT] )
+ Parent = &((Node1->Link[PARENT])->Link[Node1->gender]);
+ else
+ Parent = &(RootPtr->root);
+ ReplaceNode( Parent, Node1, dummy_p );
+
+ /* Swap Node 1 with Node 2, placing Node 1 back into the tree. */
+ if( Node2->Link[PARENT] )
+ Parent = &((Node2->Link[PARENT])->Link[Node2->gender]);
+ else
+ Parent = &(RootPtr->root);
+ ReplaceNode( Parent, Node2, Node1 );
+
+ /* Swap Node 2 and the dummy, thus placing Node 2 back into the tree. */
+ if( dummy_p->Link[PARENT] )
+ Parent = &((dummy_p->Link[PARENT])->Link[dummy_p->gender]);
+ else
+ Parent = &(RootPtr->root);
+ ReplaceNode( Parent, dummy_p, Node2 );
+ } /* SwapNodes */
+
+/* -------------------------------------------------------------------------- **
+ * These routines allow you to walk through the tree, forwards or backwards.
+ */
+
+static ubi_btNodePtr SubSlide( register ubi_btNodePtr P,
+ register char whichway )
+ /* ------------------------------------------------------------------------ **
+ * Slide down the side of a subtree.
+ *
+ * Given a starting node, this function returns a pointer to the LEFT-, or
+ * RIGHT-most descendent, *or* (if whichway is PARENT) to the tree root.
+ *
+ * Input: P - a pointer to a starting place.
+ * whichway - the direction (LEFT, RIGHT, or PARENT) in which to
+ * travel.
+ * Output: A pointer to a node that is either the root, or has no
+ * whichway-th child but is within the subtree of P. Note that
+ * the return value may be the same as P. The return value *will
+ * be* NULL if P is NULL.
+ * ------------------------------------------------------------------------ **
+ */
+ {
+ ubi_btNodePtr Q = NULL;
+
+ while( P )
+ {
+ Q = P;
+ P = P->Link[ whichway ];
+ }
+ return( Q );
+ } /* SubSlide */
+
+static ubi_btNodePtr Neighbor( register ubi_btNodePtr P,
+ register char whichway )
+ /* ------------------------------------------------------------------------ **
+ * Given starting point p, return the (key order) next or preceeding node
+ * in the tree.
+ *
+ * Input: P - Pointer to our starting place node.
+ * whichway - the direction in which to travel to find the
+ * neighbor, i.e., the RIGHT neighbor or the LEFT
+ * neighbor.
+ *
+ * Output: A pointer to the neighboring node, or NULL if P was NULL.
+ *
+ * Notes: If whichway is PARENT, the results are unpredictable.
+ * ------------------------------------------------------------------------ **
+ */
+ {
+ if( P )
+ {
+ if( P->Link[ whichway ] )
+ return( SubSlide( P->Link[ whichway ], (char)RevWay(whichway) ) );
+ else
+ while( P->Link[ PARENT ] )
+ {
+ if( (P->Link[ PARENT ])->Link[ whichway ] == P )
+ P = P->Link[ PARENT ];
+ else
+ return( P->Link[ PARENT ] );
+ }
+ }
+ return( NULL );
+ } /* Neighbor */
+
+static ubi_btNodePtr Border( ubi_btRootPtr RootPtr,
+ ubi_btItemPtr FindMe,
+ ubi_btNodePtr p,
+ char whichway )
+ /* ------------------------------------------------------------------------ **
+ * Given starting point p, which has a key value equal to *FindMe, locate
+ * the first (index order) node with the same key value.
+ *
+ * This function is useful in trees that have can have duplicate keys.
+ * For example, consider the following tree:
+ * Tree Traversal
+ * 2 If points to the root and is RIGHT, 3
+ * / \ then the return value will be a pointer to the / \
+ * 2 2 RIGHT child of the root node. The tree on 2 5
+ * / / \ the right shows the order of traversal. / / \
+ * 1 2 3 1 4 6
+ *
+ * Input: RootPtr - Pointer to the tree root structure.
+ * FindMe - Key value for comparisons.
+ * p - Pointer to the starting-point node.
+ * whichway - the direction in which to travel to find the
+ * neighbor, i.e., the RIGHT neighbor or the LEFT
+ * neighbor.
+ *
+ * Output: A pointer to the first (index, or "traversal", order) node with
+ * a Key value that matches *FindMe.
+ *
+ * Notes: If whichway is PARENT, or if the tree does not allow duplicate
+ * keys, this function will return