summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2003-01-03 08:28:12 +0000
committerAndrew Bartlett <abartlet@samba.org>2003-01-03 08:28:12 +0000
commit634c54310c92c48dd4eceec602e230a021bdcfc5 (patch)
tree9f5732a180b8daacf176e42511b0a72c972c7a4b /source3/smbd
parent47a7f0cfb5006fb41239a6cd81cce5e35fde750a (diff)
downloadsamba-634c54310c92c48dd4eceec602e230a021bdcfc5.tar.gz
samba-634c54310c92c48dd4eceec602e230a021bdcfc5.tar.bz2
samba-634c54310c92c48dd4eceec602e230a021bdcfc5.zip
Merge from HEAD - make Samba compile with -Wwrite-strings without additional
warnings. (Adds a lot of const). Andrew Bartlett (This used to be commit 3a7458f9472432ef12c43008414925fd1ce8ea0c)
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/build_options.c4
-rw-r--r--source3/smbd/connection.c6
-rw-r--r--source3/smbd/dir.c21
-rw-r--r--source3/smbd/filename.c6
-rw-r--r--source3/smbd/lanman.c37
-rw-r--r--source3/smbd/mangle.c4
-rw-r--r--source3/smbd/mangle_hash.c8
-rw-r--r--source3/smbd/negprot.c6
-rw-r--r--source3/smbd/nttrans.c2
-rw-r--r--source3/smbd/process.c4
-rw-r--r--source3/smbd/reply.c2
-rw-r--r--source3/smbd/server.c9
-rw-r--r--source3/smbd/utmp.c2
-rw-r--r--source3/smbd/vfs.c2
14 files changed, 60 insertions, 53 deletions
diff --git a/source3/smbd/build_options.c b/source3/smbd/build_options.c
index 085f287446..da5accebab 100644
--- a/source3/smbd/build_options.c
+++ b/source3/smbd/build_options.c
@@ -23,7 +23,7 @@
#include "build_env.h"
#include "dynconfig.h"
-static void output(BOOL screen, char *format, ...) PRINTF_ATTRIBUTE(2,3);
+static void output(BOOL screen, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
/*
#define OUTPUT(x) snprintf(outstring,sizeof(outstring),x); output(screen,outstring);
@@ -31,7 +31,7 @@ static void output(BOOL screen, char *format, ...) PRINTF_ATTRIBUTE(2,3);
/****************************************************************************
helper function for build_options
****************************************************************************/
-static void output(BOOL screen, char *format, ...)
+static void output(BOOL screen, const char *format, ...)
{
char *ptr;
va_list ap;
diff --git a/source3/smbd/connection.c b/source3/smbd/connection.c
index ad394a01ca..a7636e889e 100644
--- a/source3/smbd/connection.c
+++ b/source3/smbd/connection.c
@@ -35,7 +35,7 @@ TDB_CONTEXT *conn_tdb_ctx(void)
return tdb;
}
-static void make_conn_key(connection_struct *conn,char *name, TDB_DATA *pkbuf, struct connections_key *pkey)
+static void make_conn_key(connection_struct *conn, const char *name, TDB_DATA *pkbuf, struct connections_key *pkey)
{
ZERO_STRUCTP(pkey);
pkey->pid = sys_getpid();
@@ -50,7 +50,7 @@ static void make_conn_key(connection_struct *conn,char *name, TDB_DATA *pkbuf, s
Delete a connection record.
****************************************************************************/
-BOOL yield_connection(connection_struct *conn,char *name)
+BOOL yield_connection(connection_struct *conn, const char *name)
{
struct connections_key key;
TDB_DATA kbuf;
@@ -116,7 +116,7 @@ static int count_fn( TDB_CONTEXT *the_tdb, TDB_DATA kbuf, TDB_DATA dbuf, void *u
Claim an entry in the connections database.
****************************************************************************/
-BOOL claim_connection(connection_struct *conn,char *name,int max_connections,BOOL Clear, uint32 msg_flags)
+BOOL claim_connection(connection_struct *conn, const char *name,int max_connections,BOOL Clear, uint32 msg_flags)
{
struct connections_key key;
struct connections_data crec;
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index 396ecd98c4..d3c71ad24e 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -327,15 +327,20 @@ void dptr_closepath(char *path,uint16 spid)
Start a directory listing.
****************************************************************************/
-static BOOL start_dir(connection_struct *conn,char *directory)
+static BOOL start_dir(connection_struct *conn, pstring directory)
{
+ const char *dir2;
+
DEBUG(5,("start_dir dir=%s\n",directory));
if (!check_name(directory,conn))
return(False);
+
+ /* use a const pointer from here on */
+ dir2 = directory;
- if (! *directory)
- directory = ".";
+ if (! *dir2)
+ dir2 = ".";
conn->dirptr = OpenDir(conn, directory, True);
if (conn->dirptr) {
@@ -392,7 +397,7 @@ static void dptr_close_oldest(BOOL old)
me at Andrew's knee.... :-) :-). JRA.
****************************************************************************/
-int dptr_create(connection_struct *conn,char *path, BOOL old_handle, BOOL expect_close,uint16 spid)
+int dptr_create(connection_struct *conn, pstring path, BOOL old_handle, BOOL expect_close,uint16 spid)
{
dptr_struct *dptr;
@@ -812,10 +817,10 @@ static BOOL file_is_special(connection_struct *conn, char *name, SMB_STRUCT_STAT
Open a directory.
********************************************************************/
-void *OpenDir(connection_struct *conn, char *name, BOOL use_veto)
+void *OpenDir(connection_struct *conn, const char *name, BOOL use_veto)
{
Dir *dirp;
- char *n;
+ const char *n;
DIR *p = conn->vfs_ops.opendir(conn,name);
int used=0;
@@ -1009,7 +1014,7 @@ static ubi_dlNewList( dir_cache );
Output: None.
*****************************************************************************/
-void DirCacheAdd( char *path, char *name, char *dname, int snum )
+void DirCacheAdd( const char *path, char *name, char *dname, int snum )
{
int pathlen;
int namelen;
@@ -1056,7 +1061,7 @@ void DirCacheAdd( char *path, char *name, char *dname, int snum )
for large caches.
*****************************************************************************/
-char *DirCacheCheck( char *path, char *name, int snum )
+char *DirCacheCheck( const char *path, const char *name, int snum )
{
dir_cache_entry *entry;
diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c
index 202bd75d4c..bcfd366741 100644
--- a/source3/smbd/filename.c
+++ b/source3/smbd/filename.c
@@ -31,7 +31,7 @@ extern BOOL case_preserve;
extern BOOL short_case_preserve;
extern BOOL use_mangled_map;
-static BOOL scan_directory(char *path, char *name,connection_struct *conn,BOOL docache);
+static BOOL scan_directory(const char *path, pstring name,connection_struct *conn,BOOL docache);
/****************************************************************************
Check if two filenames are equal.
@@ -387,7 +387,7 @@ BOOL unix_convert(pstring name,connection_struct *conn,char *saved_last_componen
a valid one for the user to access.
****************************************************************************/
-BOOL check_name(char *name,connection_struct *conn)
+BOOL check_name(pstring name,connection_struct *conn)
{
BOOL ret;
@@ -428,7 +428,7 @@ BOOL check_name(char *name,connection_struct *conn)
If the name looks like a mangled name then try via the mangling functions
****************************************************************************/
-static BOOL scan_directory(char *path, char *name,connection_struct *conn,BOOL docache)
+static BOOL scan_directory(const char *path, pstring name,connection_struct *conn,BOOL docache)
{
void *cur_dir;
char *dname;
diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c
index 43b5d9e55f..7a667c378d 100644
--- a/source3/smbd/lanman.c
+++ b/source3/smbd/lanman.c
@@ -109,14 +109,14 @@ static char* Expand(connection_struct *conn, int snum, char* s)
/*******************************************************************
check a API string for validity when we only need to check the prefix
******************************************************************/
-static BOOL prefix_ok(char *str,char *prefix)
+static BOOL prefix_ok(const char *str, const char *prefix)
{
return(strncmp(str,prefix,strlen(prefix)) == 0);
}
struct pack_desc {
- char* format; /* formatstring for structure */
- char* subformat; /* subformat for structure */
+ const char* format; /* formatstring for structure */
+ const char* subformat; /* subformat for structure */
char* base; /* baseaddress of buffer */
int buflen; /* remaining size for fixed part; on init: length of base */
int subcount; /* count of substructures */
@@ -125,11 +125,11 @@ struct pack_desc {
char* stringbuf; /* pointer into buffer for remaining variable part */
int neededlen; /* total needed size */
int usedlen; /* total used size (usedlen <= neededlen and usedlen <= buflen) */
- char* curpos; /* current position; pointer into format or subformat */
+ const char* curpos; /* current position; pointer into format or subformat */
int errcode;
};
-static int get_counter(char** p)
+static int get_counter(const char** p)
{
int i, n;
if (!p || !(*p)) return(1);
@@ -144,7 +144,7 @@ static int get_counter(char** p)
}
}
-static int getlen(char* p)
+static int getlen(const char* p)
{
int n = 0;
if (!p) return(0);
@@ -329,7 +329,7 @@ static int package(struct pack_desc* p, ...)
#define PACKl(desc,t,v,l) package(desc,v,l)
#endif
-static void PACKI(struct pack_desc* desc,char *t,int v)
+static void PACKI(struct pack_desc* desc, const char *t,int v)
{
PACK(desc,t,v);
}
@@ -1704,7 +1704,7 @@ static BOOL api_NetUserGetGroups(connection_struct *conn,uint16 vuid, char *para
char *UserName = skip_string(str2,1);
char *p = skip_string(UserName,1);
int uLevel = SVAL(p,0);
- char *p2;
+ const char *level_string;
int count=0;
*rparam_len = 8;
@@ -1715,13 +1715,13 @@ static BOOL api_NetUserGetGroups(connection_struct *conn,uint16 vuid, char *para
return False;
switch( uLevel ) {
case 0:
- p2 = "B21";
+ level_string = "B21";
break;
default:
return False;
}
- if (strcmp(p2,str2) != 0)
+ if (strcmp(level_string,str2) != 0)
return False;
*rdata_len = mdrcnt + 1024;
@@ -2602,6 +2602,7 @@ static BOOL api_RNetUserGetInfo(connection_struct *conn,uint16 vuid, char *param
char *p = skip_string(UserName,1);
int uLevel = SVAL(p,0);
char *p2;
+ const char *level_string;
/* get NIS home of a previously validated user - simeon */
/* With share level security vuid will always be zero.
@@ -2620,15 +2621,15 @@ static BOOL api_RNetUserGetInfo(connection_struct *conn,uint16 vuid, char *param
if (strcmp(str1,"zWrLh") != 0) return False;
switch( uLevel )
{
- case 0: p2 = "B21"; break;
- case 1: p2 = "B21BB16DWzzWz"; break;
- case 2: p2 = "B21BB16DWzzWzDzzzzDDDDWb21WWzWW"; break;
- case 10: p2 = "B21Bzzz"; break;
- case 11: p2 = "B21BzzzWDDzzDDWWzWzDWb21W"; break;
+ case 0: level_string = "B21"; break;
+ case 1: level_string = "B21BB16DWzzWz"; break;
+ case 2: level_string = "B21BB16DWzzWzDzzzzDDDDWb21WWzWW"; break;
+ case 10: level_string = "B21Bzzz"; break;
+ case 11: level_string = "B21BzzzWDDzzDDWWzWzDWb21W"; break;
default: return False;
}
- if (strcmp(p2,str2) != 0) return False;
+ if (strcmp(level_string,str2) != 0) return False;
*rdata_len = mdrcnt + 1024;
*rdata = REALLOC(*rdata,*rdata_len);
@@ -3425,9 +3426,9 @@ static BOOL api_Unsupported(connection_struct *conn,uint16 vuid, char *param,cha
-const static struct
+static const struct
{
- char *name;
+ const char *name;
int id;
BOOL (*fn)(connection_struct *,uint16,char *,char *,
int,int,char **,char **,int *,int *);
diff --git a/source3/smbd/mangle.c b/source3/smbd/mangle.c
index 392e48afc1..f5c703a5bf 100644
--- a/source3/smbd/mangle.c
+++ b/source3/smbd/mangle.c
@@ -23,8 +23,8 @@
static struct mangle_fns *mangle_fns;
/* this allows us to add more mangling backends */
-static struct {
- char *name;
+static const struct {
+ const char *name;
struct mangle_fns *(*init_fn)(void);
} mangle_backends[] = {
{ "hash", mangle_hash_init },
diff --git a/source3/smbd/mangle_hash.c b/source3/smbd/mangle_hash.c
index d1c5cf1b5c..e220d2f6d2 100644
--- a/source3/smbd/mangle_hash.c
+++ b/source3/smbd/mangle_hash.c
@@ -361,15 +361,15 @@ done:
*/
static void init_chartest( void )
{
- char *illegalchars = "*\\/?<>|\":";
- unsigned char *s;
+ const char *illegalchars = "*\\/?<>|\":";
+ const unsigned char *s;
memset( (char *)chartest, '\0', 256 );
- for( s = (unsigned char *)illegalchars; *s; s++ )
+ for( s = (const unsigned char *)illegalchars; *s; s++ )
chartest[*s] = ILLEGAL_MASK;
- for( s = (unsigned char *)basechars; *s; s++ )
+ for( s = (const unsigned char *)basechars; *s; s++ )
chartest[*s] |= BASECHAR_MASK;
ct_initialized = True;
diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c
index b91c0c0866..c8f023514e 100644
--- a/source3/smbd/negprot.c
+++ b/source3/smbd/negprot.c
@@ -377,9 +377,9 @@ protocol [LANMAN2.1]
#define ARCH_ALL 0x3F
/* List of supported protocols, most desired first */
-static struct {
- char *proto_name;
- char *short_name;
+static const struct {
+ const char *proto_name;
+ const char *short_name;
int (*proto_reply_fn)(char *, char *);
int protocol_level;
} supported_protocols[] = {
diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c
index 740f450db6..29ebdce5a8 100644
--- a/source3/smbd/nttrans.c
+++ b/source3/smbd/nttrans.c
@@ -27,7 +27,7 @@ extern BOOL case_sensitive;
extern BOOL case_preserve;
extern BOOL short_case_preserve;
-static char *known_nt_pipes[] = {
+static const char *known_nt_pipes[] = {
"\\LANMAN",
"\\srvsvc",
"\\samr",
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index 923b20ad66..7421c16b40 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -339,7 +339,7 @@ force write permissions on print services.
functions. Any message that has a NULL function is unimplemented -
please feel free to contribute implementations!
*/
-const static struct smb_message_struct
+static const struct smb_message_struct
{
const char *name;
int (*fn)(connection_struct *conn, char *, char *, int, int);
@@ -890,7 +890,7 @@ return a string containing the function name of a SMB command
****************************************************************************/
const char *smb_fn_name(int type)
{
- static char *unknown_name = "SMBunknown";
+ const char *unknown_name = "SMBunknown";
if (smb_messages[type].name == NULL)
return(unknown_name);
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 4335728afc..beccc1bba6 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -271,7 +271,7 @@ int reply_tcon_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt
set_message_end(outbuf,p);
} else {
/* NT sets the fstype of IPC$ to the null string */
- char *fsname = IS_IPC(conn) ? "" : lp_fstype(SNUM(conn));
+ const char *fsname = IS_IPC(conn) ? "" : lp_fstype(SNUM(conn));
set_message(outbuf,3,0,True);
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 7581eb6001..94849f9f5c 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -179,11 +179,12 @@ static BOOL open_sockets_smbd(BOOL is_daemon,const char *smb_ports)
if (!smb_ports) {
ports = lp_smb_ports();
if (!ports || !*ports) {
- ports = SMB_PORTS;
+ ports = smb_xstrdup(SMB_PORTS);
+ } else {
+ ports = smb_xstrdup(ports);
}
- ports = strdup(ports);
} else {
- ports = strdup(smb_ports);
+ ports = smb_xstrdup(smb_ports);
}
if (lp_interfaces() && lp_bind_interfaces_only()) {
@@ -539,7 +540,7 @@ static void decrement_smbd_process_count(void)
Exit the server.
****************************************************************************/
-void exit_server(char *reason)
+void exit_server(const char *reason)
{
static int firsttime=1;
extern char *last_inbuf;
diff --git a/source3/smbd/utmp.c b/source3/smbd/utmp.c
index 6b7b0f3ad1..6c12cfac62 100644
--- a/source3/smbd/utmp.c
+++ b/source3/smbd/utmp.c
@@ -457,7 +457,7 @@ static void sys_utmp_update(struct utmp *u, const char *hostname, BOOL claim)
static int ut_id_encode(int i, char *fourbyte)
{
int nbase;
- char *ut_id_encstr = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ const char *ut_id_encstr = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
fourbyte[0] = 'S';
fourbyte[1] = 'M';
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c
index 7e60d3dacb..7b8d9d7e9e 100644
--- a/source3/smbd/vfs.c
+++ b/source3/smbd/vfs.c
@@ -781,7 +781,7 @@ char *vfs_GetWd(connection_struct *conn, char *path)
Widelinks are allowed if widelinks is true.
********************************************************************/
-BOOL reduce_name(connection_struct *conn, char *s,char *dir,BOOL widelinks)
+BOOL reduce_name(connection_struct *conn, pstring s, const char *dir,BOOL widelinks)
{
#ifndef REDUCE_PATHS
return True;