[SCM] Samba Shared Repository - branch v3-2-test updated -
initial-v3-2-unstable-320-g1ea3ac8
Jeremy Allison
jra at samba.org
Thu Nov 15 22:20:34 GMT 2007
The branch, v3-2-test has been updated
via 1ea3ac80146b83c2522b69e7747c823366a2b47d (commit)
from b3ed3f7e4e40c4f78d4c347411c75de81979455f (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test
- Log -----------------------------------------------------------------
commit 1ea3ac80146b83c2522b69e7747c823366a2b47d
Author: Jeremy Allison <jra at samba.org>
Date: Thu Nov 15 14:19:52 2007 -0800
More pstring removal. This one was tricky. I had to add
one horror (pstring_clean_name()) which will have to
remain until I've removed all pstrings from the client code.
Jeremy.
-----------------------------------------------------------------------
Summary of changes:
source/client/client.c | 16 ++-
source/client/clitar.c | 2 +-
source/client/smbctool.c | 11 +-
source/include/debug.h | 1 -
source/lib/afs.c | 18 ++-
source/lib/debug.c | 105 ++++++++++------
source/lib/fault.c | 29 +++--
source/lib/popt_common.c | 26 +++--
source/lib/readline.c | 13 ++-
source/lib/smbldap_util.c | 93 +++++++++-----
source/lib/sysquotas.c | 44 ++++---
source/lib/util.c | 204 +++++++++++++++++--------------
source/lib/util_file.c | 4 +-
source/lib/util_unistr.c | 52 +++++++--
source/libsmb/clidfs.c | 8 +-
source/nmbd/nmbd.c | 2 +
source/param/loadparm.c | 2 +-
source/printing/nt_printing.c | 246 ++++++++++++++++++++++++++++---------
source/rpc_server/srv_srvsvc_nt.c | 21 ++--
source/rpc_server/srv_winreg_nt.c | 27 ++--
source/smbd/server.c | 5 +-
source/utils/smbcacls.c | 3 +-
source/web/swat.c | 3 +
source/winbindd/winbindd.c | 4 +-
24 files changed, 623 insertions(+), 316 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source/client/client.c b/source/client/client.c
index 94dc52d..1c54b2d 100644
--- a/source/client/client.c
+++ b/source/client/client.c
@@ -283,7 +283,7 @@ static int do_cd(char *newdir)
}
}
- clean_name(cur_dir);
+ pstring_clean_name(cur_dir);
pstrcpy( dname, cur_dir );
if ( !cli_resolve_path( "", cli, dname, &targetcli, targetpath ) ) {
@@ -313,7 +313,7 @@ static int do_cd(char *newdir)
}
} else {
pstrcat( targetpath, CLI_DIRSEP_STR );
- clean_name( targetpath );
+ pstring_clean_name( targetpath );
if ( !cli_chkpath(targetcli, targetpath) ) {
d_printf("cd %s: %s\n", dname, cli_errstr(targetcli));
@@ -953,7 +953,7 @@ static int cmd_get(void)
return 1;
}
pstrcpy(lname,p);
- clean_name(rname);
+ pstring_clean_name(rname);
next_token_nr(NULL,lname,NULL,sizeof(lname));
@@ -1054,7 +1054,7 @@ static int cmd_more(void)
unlink(lname);
return 1;
}
- clean_name(rname);
+ pstring_clean_name(rname);
rc = do_get(rname, lname, False);
@@ -1393,7 +1393,7 @@ static int cmd_put(void)
else
pstrcat(rname,lname);
- clean_name(rname);
+ pstring_clean_name(rname);
{
SMB_STRUCT_STAT st;
@@ -2949,7 +2949,7 @@ static int cmd_reget(void)
return 1;
}
pstrcpy(local_name, p);
- clean_name(remote_name);
+ pstring_clean_name(remote_name);
next_token_nr(NULL, local_name, NULL, sizeof(local_name));
@@ -2987,7 +2987,7 @@ static int cmd_reput(void)
else
pstrcat(remote_name, local_name);
- clean_name(remote_name);
+ pstring_clean_name(remote_name);
return do_put(remote_name, local_name, True);
}
@@ -3960,6 +3960,7 @@ static int do_message_op(void)
POPT_COMMON_CREDENTIALS
POPT_TABLEEND
};
+ TALLOC_CTX *frame = talloc_stackframe();
load_case_tables();
@@ -4205,5 +4206,6 @@ static int do_message_op(void)
}
talloc_destroy( ctx);
+ talloc_destroy(frame);
return rc;
}
diff --git a/source/client/clitar.c b/source/client/clitar.c
index 0c82017..4ce92c6 100644
--- a/source/client/clitar.c
+++ b/source/client/clitar.c
@@ -651,7 +651,7 @@ static void do_atar(char *rname,char *lname,file_info *finfo1)
fnum = cli_open(cli, rname, O_RDONLY, DENY_NONE);
- clean_name(rname);
+ pstring_clean_name(rname);
if (fnum == -1) {
DEBUG(0,("%s opening remote file %s (%s)\n",
diff --git a/source/client/smbctool.c b/source/client/smbctool.c
index e7ac802..b563a33 100644
--- a/source/client/smbctool.c
+++ b/source/client/smbctool.c
@@ -367,7 +367,7 @@ static int do_cd(char *newdir)
all_string_sub(cur_dir, "/./", "/", 0);
/* Format the directory in a libmsmbclient friendly way */
- clean_name(cur_dir);
+ pstring_clean_name(cur_dir);
all_string_sub(cur_dir, "/./", "/", 0);
pstrcpy(targetpath, "smb:");
pstrcat(targetpath, service);
@@ -1129,7 +1129,7 @@ static int cmd_more(void)
unlink(lname);
return 1;
}
- clean_name(rname);
+ pstring_clean_name(rname);
rc = do_get(rname, lname, False);
@@ -2677,7 +2677,7 @@ static int cmd_reget(void)
return 1;
}
pstrcpy(local_name, p);
- clean_name(remote_name);
+ pstring_clean_name(remote_name);
next_token_nr(NULL, local_name, NULL, sizeof(local_name));
@@ -2715,7 +2715,7 @@ static int cmd_reput(void)
else
pstrcat(remote_name, local_name);
- clean_name(remote_name);
+ pstring_clean_name(remote_name);
return do_put(remote_name, local_name, True);
}
@@ -3549,7 +3549,7 @@ static int do_message_op(void)
POPT_COMMON_CREDENTIALS
POPT_TABLEEND
};
-
+ TALLOC_CTX *frame = talloc_stackframe();
#ifdef KANJI
pstrcpy(term_code, KANJI);
@@ -3766,5 +3766,6 @@ static int do_message_op(void)
return 1;
}
+ TALLOC_FREE(frame);
return rc;
}
diff --git a/source/include/debug.h b/source/include/debug.h
index 5185092..46e5620 100644
--- a/source/include/debug.h
+++ b/source/include/debug.h
@@ -49,7 +49,6 @@ bool dbghdr( int level, int cls, const char *file, const char *func, int line );
#endif
extern XFILE *dbf;
-extern pstring debugf;
/* If we have these macros, we can add additional info to the header. */
diff --git a/source/lib/afs.c b/source/lib/afs.c
index 35f213f..dadd83d 100644
--- a/source/lib/afs.c
+++ b/source/lib/afs.c
@@ -213,10 +213,10 @@ bool afs_login(connection_struct *conn)
extern userdom_struct current_user_info;
extern struct current_user current_user;
DATA_BLOB ticket;
- pstring afs_username;
- char *cell;
+ char *afs_username = NULL;
+ char *cell = NULL;
bool result;
- char *ticket_str;
+ char *ticket_str = NULL;
const DOM_SID *user_sid;
struct ClearToken ct;
@@ -229,7 +229,13 @@ bool afs_login(connection_struct *conn)
afs_username, sizeof(afs_username));
user_sid = ¤t_user.nt_user_token->user_sids[0];
- pstring_sub(afs_username, "%s", sid_string_static(user_sid));
+ afs_username = talloc_string_sub(talloc_tos(),
+ lp_afs_username_map(),
+ "%s",
+ sid_string_static(user_sid));
+ if (!afs_username) {
+ return false;
+ }
/* The pts command always generates completely lower-case user
* names. */
@@ -240,13 +246,13 @@ bool afs_login(connection_struct *conn)
if (cell == NULL) {
DEBUG(1, ("AFS username doesn't contain a @, "
"could not find cell\n"));
- return False;
+ return false;
}
*cell = '\0';
cell += 1;
- DEBUG(10, ("Trying to log into AFS for user %s@%s\n",
+ DEBUG(10, ("Trying to log into AFS for user %s@%s\n",
afs_username, cell));
if (!afs_createtoken(afs_username, cell, &ticket, &ct))
diff --git a/source/lib/debug.c b/source/lib/debug.c
index 7228527..49ec40a 100644
--- a/source/lib/debug.c
+++ b/source/lib/debug.c
@@ -29,7 +29,8 @@
* for a terminating null byte.
*/
-#define FORMAT_BUFR_MAX ( sizeof( format_bufr ) - 1 )
+#define FORMAT_BUFR_SIZE 1024
+#define FORMAT_BUFR_MAX (FORMAT_BUFR_SIZE - 1)
/* -------------------------------------------------------------------------- **
* This module implements Samba's debugging utility.
@@ -78,16 +79,16 @@
*/
XFILE *dbf = NULL;
-pstring debugf = "";
+static char *debugf = NULL;
bool debug_warn_unknown_class = True;
bool debug_auto_add_unknown_class = True;
bool AllowDebugChange = True;
-/*
- used to check if the user specified a
- logfile on the command line
+/*
+ used to check if the user specified a
+ logfile on the command line
*/
-bool override_logfile;
+bool override_logfile;
/*
@@ -137,7 +138,7 @@ static int debug_count = 0;
#ifdef WITH_SYSLOG
static int syslog_level = 0;
#endif
-static pstring format_bufr = { '\0' };
+static char *format_bufr = NULL;
static size_t format_pos = 0;
static bool log_overflow = False;
@@ -536,6 +537,10 @@ void debug_init(void)
for(p = default_classname_table; *p; p++) {
debug_add_class(*p);
}
+ format_bufr = SMB_MALLOC(FORMAT_BUFR_SIZE);
+ if (!format_bufr) {
+ smb_panic("debug_init: unable to create buffer");
+ }
}
void debug_register_msgs(struct messaging_context *msg_ctx)
@@ -583,6 +588,16 @@ void setup_logging(const char *pname, bool interactive)
#endif
}
+/***************************************************************************
+ Set the logfile name.
+**************************************************************************/
+
+void debug_set_logfile(const char *name)
+{
+ SAFE_FREE(debugf);
+ debugf = SMB_STRDUP(name);
+}
+
/**************************************************************************
reopen the log files
note that we now do this unconditionally
@@ -593,7 +608,7 @@ void setup_logging(const char *pname, bool interactive)
bool reopen_logs( void )
{
- pstring fname;
+ char *fname = NULL;
mode_t oldumask;
XFILE *new_dbf = NULL;
XFILE *old_dbf = NULL;
@@ -603,19 +618,27 @@ bool reopen_logs( void )
return True;
oldumask = umask( 022 );
-
- pstrcpy(fname, debugf );
- debugf[0] = '\0';
+
+ fname = debugf;
+ if (!fname) {
+ return false;
+ }
+ debugf = NULL;
if (lp_loaded()) {
char *logfname;
logfname = lp_logfile();
- if (*logfname)
- pstrcpy(fname, logfname);
+ if (*logfname) {
+ SAFE_FREE(fname);
+ fname = SMB_STRDUP(logfname);
+ if (!fname) {
+ return false;
+ }
+ }
}
- pstrcpy( debugf, fname );
+ debugf = fname;
new_dbf = x_fopen( debugf, O_WRONLY|O_APPEND|O_CREAT, 0644);
if (!new_dbf) {
@@ -702,15 +725,18 @@ void check_log_size( void )
if( sys_fstat( x_fileno( dbf ), &st ) == 0 && st.st_size > maxlog ) {
(void)reopen_logs();
if( dbf && get_file_size( debugf ) > maxlog ) {
- pstring name;
+ char *name = NULL;
+
+ if (asprintf(&name, "%s.old", debugf ) < 0) {
+ return;
+ }
+ (void)rename(debugf, name);
- slprintf( name, sizeof(name)-1, "%s.old", debugf );
- (void)rename( debugf, name );
-
if (!reopen_logs()) {
/* We failed to reopen a log - continue using the old name. */
(void)rename(name, debugf);
}
+ SAFE_FREE(name);
}
}
@@ -747,7 +773,7 @@ void check_log_size( void )
int Debug1( const char *format_str, ... )
{
- va_list ap;
+ va_list ap;
int old_errno = errno;
debug_count++;
@@ -762,8 +788,8 @@ void check_log_size( void )
}
/* prevent recursion by checking if reopen_logs() has temporaily
- set the debugf string to "" */
- if( debugf[0] == '\0')
+ set the debugf string to NULL */
+ if( debugf == NULL)
return( 0 );
#ifdef WITH_SYSLOG
@@ -789,29 +815,31 @@ void check_log_size( void )
/* map debug levels to syslog() priorities
* note that not all DEBUG(0, ...) calls are
* necessarily errors */
- static int priority_map[] = {
+ static int priority_map[] = {
LOG_ERR, /* 0 */
LOG_WARNING, /* 1 */
LOG_NOTICE, /* 2 */
LOG_INFO, /* 3 */
};
int priority;
- pstring msgbuf;
+ char *msgbuf = NULL;
if( syslog_level >= ( sizeof(priority_map) / sizeof(priority_map[0]) ) || syslog_level < 0)
priority = LOG_DEBUG;
else
priority = priority_map[syslog_level];
- va_start( ap, format_str );
- vslprintf( msgbuf, sizeof(msgbuf)-1, format_str, ap );
- va_end( ap );
+ va_start(ap, format_str);
+ vasprintf(&msgbuf, format_str, ap);
+ va_end(ap);
- msgbuf[255] = '\0';
- syslog( priority, "%s", msgbuf );
+ if (msgbuf) {
+ syslog(priority, "%s", msgbuf);
+ }
+ SAFE_FREE(msgbuf);
}
#endif
-
+
check_log_size();
#ifdef WITH_SYSLOG
@@ -1018,13 +1046,18 @@ bool dbghdr(int level, int cls, const char *file, const char *func, int line)
bool dbgtext( const char *format_str, ... )
{
va_list ap;
- pstring msgbuf;
-
- va_start( ap, format_str );
- vslprintf( msgbuf, sizeof(msgbuf)-1, format_str, ap );
- va_end( ap );
+ char *msgbuf = NULL;
+ bool ret = true;
- format_debug_text( msgbuf );
+ va_start(ap, format_str);
+ vasprintf(&msgbuf, format_str, ap);
+ va_end(ap);
- return( True );
+ if (msgbuf) {
+ format_debug_text(msgbuf);
+ } else {
+ ret = false;
+ }
+ SAFE_FREE(msgbuf);
+ return ret;
}
diff --git a/source/lib/fault.c b/source/lib/fault.c
index 6ab1a07..52c4ae6 100644
--- a/source/lib/fault.c
+++ b/source/lib/fault.c
@@ -24,7 +24,7 @@
#endif
static void (*cont_fn)(void *);
-static pstring corepath;
+static char *corepath;
/*******************************************************************
report a fault
@@ -93,11 +93,13 @@ make all the preparations to safely dump a core file
void dump_core_setup(const char *progname)
{
- pstring logbase;
- char * end;
+ char *logbase = NULL;
+ char *end = NULL;
if (lp_logfile() && *lp_logfile()) {
- snprintf(logbase, sizeof(logbase), "%s", lp_logfile());
+ if (asprintf(&logbase, "%s", lp_logfile()) < 0) {
+ return;
+ }
if ((end = strrchr_m(logbase, '/'))) {
*end = '\0';
}
@@ -106,21 +108,32 @@ void dump_core_setup(const char *progname)
* line by the -l option but the "log file" option is not set
* in smb.conf.
*/
- snprintf(logbase, sizeof(logbase), "%s", dyn_LOGFILEBASE);
+ if (asprintf(&logbase, "%s", dyn_LOGFILEBASE) < 0) {
+ return;
+ }
}
SMB_ASSERT(progname != NULL);
- snprintf(corepath, sizeof(corepath), "%s/cores", logbase);
+ if (asprintf(&corepath, "%s/cores", logbase) < 0) {
+ SAFE_FREE(logbase);
+ return;
+ }
mkdir(corepath,0700);
- snprintf(corepath, sizeof(corepath), "%s/cores/%s",
- logbase, progname);
+ SAFE_FREE(corepath);
+ if (asprintf(&corepath, "%s/cores/%s",
+ logbase, progname) < 0) {
+ SAFE_FREE(logbase);
+ return;
+ }
mkdir(corepath,0700);
sys_chown(corepath,getuid(),getgid());
chmod(corepath,0700);
+ SAFE_FREE(corepath);
--
Samba Shared Repository
More information about the samba-cvs
mailing list