summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/Makefile.in2
-rw-r--r--source3/aparser/parser.h2
-rw-r--r--source3/client/client.c38
-rw-r--r--source3/client/clitar.c12
-rw-r--r--source3/client/smbmount.c2
-rw-r--r--source3/include/includes.h1
-rw-r--r--source3/include/smb_macros.h2
-rw-r--r--source3/lib/cmd_interp.c14
-rw-r--r--source3/lib/debug.c34
-rw-r--r--source3/lib/readline.c6
-rw-r--r--source3/lib/util.c10
-rw-r--r--source3/nmbd/nmbd.c4
-rw-r--r--source3/script/mkproto.awk2
-rw-r--r--source3/smbd/server.c5
-rw-r--r--source3/smbwrapper/smbsh.c4
-rw-r--r--source3/smbwrapper/smbw.c4
-rw-r--r--source3/torture/locktest.c4
-rw-r--r--source3/torture/locktest2.c4
-rw-r--r--source3/torture/masktest.c4
-rw-r--r--source3/torture/rpctorture.c4
-rw-r--r--source3/torture/torture.c4
-rw-r--r--source3/utils/smbcacls.c4
-rw-r--r--source3/utils/smbtree.c4
-rw-r--r--source3/utils/status.c4
-rw-r--r--source3/utils/testparm.c4
-rw-r--r--source3/utils/testprns.c6
-rw-r--r--source3/web/cgi.c6
-rw-r--r--source3/web/swat.c6
28 files changed, 86 insertions, 110 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in
index 5f0ca9c16f..30036889b2 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -107,7 +107,7 @@ LIB_OBJ = lib/charcnv.o lib/debug.o lib/fault.o \
lib/interfaces.o lib/pidfile.o lib/replace.o \
lib/signal.o lib/system.o lib/time.o \
lib/ufc.o lib/genrand.o lib/username.o lib/access.o lib/smbrun.o \
- lib/bitmap.o lib/crc32.o lib/snprintf.o lib/dprintf.o lib/wins_srv.o \
+ lib/bitmap.o lib/crc32.o lib/snprintf.o lib/dprintf.o lib/xfile.o lib/wins_srv.o \
lib/util_array.o lib/util_str.o lib/util_sid.o \
lib/util_unistr.o lib/util_file.o lib/sysacls.o \
lib/util.o lib/util_sock.o lib/util_sec.o smbd/ssl.o \
diff --git a/source3/aparser/parser.h b/source3/aparser/parser.h
index 3d6540d8a7..319aeb5d13 100644
--- a/source3/aparser/parser.h
+++ b/source3/aparser/parser.h
@@ -52,7 +52,7 @@ typedef char fstring[FSTRING_LEN];
#define True 1
/* zero a structure given a pointer to the structure */
-#define ZERO_STRUCTP(x) { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); }
+#define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); } while(0)
#define MAX_UNISTRLEN 256
#define MAX_STRINGLEN 256
diff --git a/source3/client/client.c b/source3/client/client.c
index 5612fc64b8..c9842335a9 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -135,17 +135,17 @@ static int writefile(int f, char *b, int n)
read from a file with LF->CR/LF translation if appropriate. return the
number read. read approx n bytes.
****************************************************************************/
-static int readfile(char *b, int n, FILE *f)
+static int readfile(char *b, int n, XFILE *f)
{
int i;
int c;
if (!translation)
- return fread(b,1,n,f);
+ return x_fread(b,1,n,f);
i = 0;
while (i < (n - 1) && (i < BUFFER_SIZE)) {
- if ((c = getc(f)) == EOF) {
+ if ((c = x_getc(f)) == EOF) {
break;
}
@@ -981,7 +981,7 @@ static void cmd_mkdir(void)
static void do_put(char *rname,char *lname)
{
int fnum;
- FILE *f;
+ XFILE *f;
int nread=0;
char *buf=NULL;
int maxwrite=io_bufsize;
@@ -999,10 +999,10 @@ static void do_put(char *rname,char *lname)
/* allow files to be piped into smbclient
jdblair 24.jun.98 */
if (!strcmp(lname, "-")) {
- f = stdin;
+ f = x_stdin;
/* size of file is not known */
} else {
- f = sys_fopen(lname,"r");
+ f = x_fopen(lname,O_RDONLY, 0);
}
if (!f) {
@@ -1019,12 +1019,12 @@ static void do_put(char *rname,char *lname)
d_printf("ERROR: Not enough memory!\n");
return;
}
- while (!feof(f)) {
+ while (!x_feof(f)) {
int n = maxwrite;
int ret;
if ((n = readfile(buf,n,f)) < 1) {
- if((n == 0) && feof(f))
+ if((n == 0) && x_feof(f))
break; /* Empty local file. */
d_printf("Error reading local file: %s\n", strerror(errno));
@@ -1043,13 +1043,13 @@ static void do_put(char *rname,char *lname)
if (!cli_close(cli, fnum)) {
d_printf("%s closing remote file %s\n",cli_errstr(cli),rname);
- fclose(f);
+ x_fclose(f);
if (buf) free(buf);
return;
}
- fclose(f);
+ x_fclose(f);
if (buf) free(buf);
{
@@ -1068,7 +1068,7 @@ static void do_put(char *rname,char *lname)
put_total_size / (1.024*put_total_time_ms)));
}
- if (f == stdin) {
+ if (f == x_stdin) {
cli_shutdown(cli);
exit(0);
}
@@ -2280,7 +2280,7 @@ static int do_message_op(void)
fstring base_directory;
char *pname = argv[0];
int opt;
- extern FILE *dbf;
+ extern XFILE *dbf;
extern char *optarg;
extern int optind;
int old_debug;
@@ -2315,7 +2315,7 @@ static int do_message_op(void)
for (opt = 1; opt < argc; opt++) {
if (strcmp(argv[opt], "-E") == 0)
- dbf = stderr;
+ dbf = x_stderr;
else if(strncmp(argv[opt], "-s", 2) == 0) {
if(argv[opt][2] != '\0')
pstrcpy(servicesf, &argv[opt][2]);
@@ -2473,7 +2473,7 @@ static int do_message_op(void)
break;
case 'E':
display_set_stderr();
- dbf = stderr;
+ dbf = x_stderr;
break;
case 'U':
{
@@ -2490,22 +2490,22 @@ static int do_message_op(void)
case 'A':
{
- FILE *auth;
+ XFILE *auth;
fstring buf;
uint16 len = 0;
char *ptr, *val, *param;
- if ((auth=sys_fopen(optarg, "r")) == NULL)
+ if ((auth=x_fopen(optarg, O_RDONLY, 0)) == NULL)
{
/* fail if we can't open the credentials file */
d_printf("ERROR: Unable to open credentials file!\n");
exit (-1);
}
- while (!feof(auth))
+ while (!x_feof(auth))
{
/* get a line from the file */
- if (!fgets (buf, sizeof(buf), auth))
+ if (!x_fgets(buf, sizeof(buf), auth))
continue;
len = strlen(buf);
@@ -2539,7 +2539,7 @@ static int do_message_op(void)
memset(buf, 0, sizeof(buf));
}
- fclose(auth);
+ x_fclose(auth);
}
break;
diff --git a/source3/client/clitar.c b/source3/client/clitar.c
index 8ce73f6645..6169c9af46 100644
--- a/source3/client/clitar.c
+++ b/source3/client/clitar.c
@@ -71,7 +71,7 @@ stack dir_stack = {NULL, 0}; /* Want an empty stack */
#define SEPARATORS " \t\n\r"
extern int DEBUGLEVEL;
extern struct cli_state *cli;
-extern FILE *dbf;
+extern XFILE *dbf;
/* These defines are for the do_setrattr routine, to indicate
* setting and reseting of file attributes in the function call */
@@ -1533,7 +1533,7 @@ accordingly.
***************************************************************************/
static int read_inclusion_file(char *filename)
{
- FILE *inclusion = NULL;
+ XFILE *inclusion = NULL;
char buf[MAXPATHLEN + 1];
char *inclusion_buffer = NULL;
int inclusion_buffer_size = 0;
@@ -1545,7 +1545,7 @@ static int read_inclusion_file(char *filename)
clipn = 0;
buf[MAXPATHLEN] = '\0'; /* guarantee null-termination */
- if ((inclusion = sys_fopen(filename, "r")) == NULL) {
+ if ((inclusion = x_fopen(filename, O_RDONLY, 0)) == NULL) {
/* XXX It would be better to include a reason for failure, but without
* autoconf, it's hard to use strerror, sys_errlist, etc.
*/
@@ -1553,7 +1553,7 @@ static int read_inclusion_file(char *filename)
return 0;
}
- while ((! error) && (fgets(buf, sizeof(buf)-1, inclusion))) {
+ while ((! error) && (x_fgets(buf, sizeof(buf)-1, inclusion))) {
if (inclusion_buffer == NULL) {
inclusion_buffer_size = 1024;
if ((inclusion_buffer = malloc(inclusion_buffer_size)) == NULL) {
@@ -1584,7 +1584,7 @@ static int read_inclusion_file(char *filename)
inclusion_buffer_sofar += strlen(buf) + 1;
clipn++;
}
- fclose(inclusion);
+ x_fclose(inclusion);
if (! error) {
/* Allocate an array of clipn + 1 char*'s for cliplist */
@@ -1827,7 +1827,7 @@ int tar_parseargs(int argc, char *argv[], char *Optarg, int Optind)
* tar output
*/
if (tarhandle == 1)
- dbf = stderr;
+ dbf = x_stderr;
} else {
if (tar_type=='c' && (dry_run || strcmp(argv[Optind], "/dev/null")==0))
{
diff --git a/source3/client/smbmount.c b/source3/client/smbmount.c
index 71c7e29810..a87eb789ef 100644
--- a/source3/client/smbmount.c
+++ b/source3/client/smbmount.c
@@ -148,7 +148,7 @@ static struct cli_state *do_connection(char *service)
if (have_ip) ip = dest_ip;
/* have to open a new connection */
- if (!(c=cli_initialise(NULL)) || (cli_set_port(c, smb_port) != port) ||
+ if (!(c=cli_initialise(NULL)) || (cli_set_port(c, smb_port) != smb_port) ||
!cli_connect(c, server_n, &ip)) {
DEBUG(0,("%d: Connection to %s failed\n", getpid(), server_n));
if (c) {
diff --git a/source3/include/includes.h b/source3/include/includes.h
index df0448bb9c..1f97a2d7ed 100644
--- a/source3/include/includes.h
+++ b/source3/include/includes.h
@@ -640,6 +640,7 @@ extern int errno;
#include "messages.h"
#include "util_list.h"
#include "charset.h"
+#include "xfile.h"
#include "util_getent.h"
diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h
index 315cb5e5ee..52649ffc39 100644
--- a/source3/include/smb_macros.h
+++ b/source3/include/smb_macros.h
@@ -41,7 +41,7 @@
#define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x))
/* zero a structure given a pointer to the structure */
-#define ZERO_STRUCTP(x) { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); }
+#define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); } while(0)
/* zero a structure given a pointer to the structure - no zero check */
#define ZERO_STRUCTPN(x) memset((char *)(x), 0, sizeof(*(x)))
diff --git a/source3/lib/cmd_interp.c b/source3/lib/cmd_interp.c
index 1d31d78b94..fed3d65d62 100644
--- a/source3/lib/cmd_interp.c
+++ b/source3/lib/cmd_interp.c
@@ -198,16 +198,6 @@ do a (presumably graceful) quit...
****************************************************************************/
static uint32 cmd_quit(struct client_info *info, int argc, char *argv[])
{
-#ifdef MEM_MAN
- {
- extern FILE *dbf;
- smb_mem_write_status(dbf);
- smb_mem_write_errors(dbf);
- smb_mem_write_verbose(dbf);
- dbgflush();
- }
-#endif
-
free_connections();
exit(0);
@@ -927,7 +917,7 @@ static uint32 cmd_set(CLIENT_INFO *info, int argc, char *argv[])
BOOL interactive = True;
char *cmd_str = NULL;
int opt;
- extern FILE *dbf;
+ extern XFILE *dbf;
extern char *optarg;
static pstring servicesf = CONFIGFILE;
pstring term_code;
@@ -1048,7 +1038,7 @@ static uint32 cmd_set(CLIENT_INFO *info, int argc, char *argv[])
case 'E':
{
cmd_set_options |= CMD_DBG;
- dbf = stderr;
+ dbf = x_stderr;
break;
}
diff --git a/source3/lib/debug.c b/source3/lib/debug.c
index 4dbeda2f73..9eb490c27e 100644
--- a/source3/lib/debug.c
+++ b/source3/lib/debug.c
@@ -79,7 +79,7 @@
* levels higher than DEBUGLEVEL will not be processed.
*/
-FILE *dbf = NULL;
+XFILE *dbf = NULL;
pstring debugf = "";
BOOL append_log = False;
@@ -308,7 +308,7 @@ void setup_logging(char *pname, BOOL interactive)
if (interactive) {
stdout_logging = True;
- dbf = stdout;
+ dbf = x_stdout;
}
#ifdef WITH_SYSLOG
else {
@@ -337,7 +337,7 @@ BOOL reopen_logs( void )
{
pstring fname;
mode_t oldumask;
- FILE *new_dbf = NULL;
+ XFILE *new_dbf = NULL;
BOOL ret = True;
if (stdout_logging)
@@ -351,20 +351,20 @@ BOOL reopen_logs( void )
pstrcpy( debugf, fname );
if (append_log)
- new_dbf = sys_fopen( debugf, "a" );
+ new_dbf = x_fopen( debugf, O_WRONLY|O_APPEND|O_CREAT, 0644);
else
- new_dbf = sys_fopen( debugf, "w" );
+ new_dbf = x_fopen( debugf, O_WRONLY|O_CREAT|O_TRUNC, 0644 );
if (!new_dbf) {
log_overflow = True;
DEBUG(0, ("Unable to open new log file %s: %s\n", debugf, strerror(errno)));
log_overflow = False;
- fflush(dbf);
+ x_fflush(dbf);
ret = False;
} else {
- setbuf(new_dbf, NULL);
+ x_setbuf(new_dbf, NULL);
if (dbf)
- (void) fclose(dbf);
+ (void) x_fclose(dbf);
dbf = new_dbf;
}
@@ -429,7 +429,7 @@ void check_log_size( void )
maxlog = lp_max_log_size() * 1024;
- if( sys_fstat( fileno( dbf ), &st ) == 0 && st.st_size > maxlog ) {
+ if( sys_fstat( x_fileno( dbf ), &st ) == 0 && st.st_size > maxlog ) {
(void)reopen_logs();
if( dbf && get_file_size( debugf ) > maxlog ) {
pstring name;
@@ -456,7 +456,7 @@ void check_log_size( void )
startup or when the log level is increased from zero.
-dwg 6 June 2000
*/
- dbf = sys_fopen( "/dev/console", "w" );
+ dbf = x_fopen( "/dev/console", O_WRONLY, 0);
if(dbf) {
DEBUG(0,("check_log_size: open of debug file %s failed - using console.\n",
debugf ));
@@ -484,7 +484,7 @@ void check_log_size( void )
{
va_start( ap, format_str );
if(dbf)
- (void)vfprintf( dbf, format_str, ap );
+ (void)x_vfprintf( dbf, format_str, ap );
va_end( ap );
errno = old_errno;
return( 0 );
@@ -499,13 +499,13 @@ void check_log_size( void )
mode_t oldumask = umask( 022 );
if( append_log )
- dbf = sys_fopen( debugf, "a" );
+ dbf = x_fopen( debugf, O_WRONLY|O_APPEND|O_CREAT, 0644 );
else
- dbf = sys_fopen( debugf, "w" );
+ dbf = x_fopen( debugf, O_WRONLY|O_CREAT|O_TRUNC, 0644 );
(void)umask( oldumask );
if( dbf )
{
- setbuf( dbf, NULL );
+ x_setbuf( dbf, NULL );
}
else
{
@@ -554,10 +554,10 @@ void check_log_size( void )
{
va_start( ap, format_str );
if(dbf)
- (void)vfprintf( dbf, format_str, ap );
+ (void)x_vfprintf( dbf, format_str, ap );
va_end( ap );
if(dbf)
- (void)fflush( dbf );
+ (void)x_fflush( dbf );
}
errno = old_errno;
@@ -647,7 +647,7 @@ void dbgflush( void )
{
bufr_print();
if(dbf)
- (void)fflush( dbf );
+ (void)x_fflush( dbf );
} /* dbgflush */
/* ************************************************************************** **
diff --git a/source3/lib/readline.c b/source3/lib/readline.c
index 11d65a2b16..b03d37695e 100644
--- a/source3/lib/readline.c
+++ b/source3/lib/readline.c
@@ -49,14 +49,14 @@ static char *smb_readline_replacement(char *prompt, void (*callback)(void),
int end))
{
fd_set fds;
- extern FILE *dbf;
+ extern XFILE *dbf;
static pstring line;
struct timeval timeout;
int fd = fileno(stdin);
char *ret;
- fprintf(dbf, "%s", prompt);
- fflush(dbf);
+ x_fprintf(dbf, "%s", prompt);
+ x_fflush(dbf);
while (1) {
timeout.tv_sec = 5;
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 9b92e412d0..d1d052d4a0 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -630,16 +630,6 @@ BOOL yesno(char *p)
return(False);
}
-#ifdef HPUX
-/****************************************************************************
-this is a version of setbuffer() for those machines that only have setvbuf
-****************************************************************************/
- void setbuffer(FILE *f,char *buf,int bufsize)
-{
- setvbuf(f,buf,_IOFBF,bufsize);
-}
-#endif
-
/****************************************************************************
expand a pointer to be a particular size
****************************************************************************/
diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c
index 87c539371b..141d055281 100644
--- a/source3/nmbd/nmbd.c
+++ b/source3/nmbd/nmbd.c
@@ -666,7 +666,7 @@ static void usage(char *pname)
int main(int argc,char *argv[])
{
int opt;
- extern FILE *dbf;
+ extern XFILE *dbf;
extern char *optarg;
extern BOOL append_log;
@@ -876,7 +876,7 @@ static void usage(char *pname)
process();
if (dbf)
- fclose(dbf);
+ x_fclose(dbf);
return(0);
} /* main */
diff --git a/source3/script/mkproto.awk b/source3/script/mkproto.awk
index 200e4243bc..097031590e 100644
--- a/source3/script/mkproto.awk
+++ b/source3/script/mkproto.awk
@@ -126,7 +126,7 @@ END {
gotstart = 1;
}
- if( $0 ~ /^smb_iconv_t|^long|^char|^uint|^NTSTATUS|^WERROR|^struct|^BOOL|^void|^time|^smb_shm_offset_t|^shm_offset_t|^FILE|^SMB_OFF_T|^size_t|^ssize_t|^SMB_BIG_UINT/ ) {
+ if( $0 ~ /^smb_iconv_t|^long|^char|^uint|^NTSTATUS|^WERROR|^struct|^BOOL|^void|^time|^smb_shm_offset_t|^shm_offset_t|^FILE|^XFILE|^SMB_OFF_T|^size_t|^ssize_t|^SMB_BIG_UINT/ ) {
gotstart = 1;
}
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 36c98300f0..1dfff6cafa 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -781,11 +781,6 @@ static void usage(char *pname)
/* Setup the main smbd so that we can get messages. */
claim_connection(NULL,"",MAXSTATUS,True);
- /* Attempt to migrate from an old 2.0.x machine account file. */
- if (!migrate_from_old_password_file(global_myworkgroup)) {
- DEBUG(0,("Failed to migrate from old MAC file.\n"));
- }
-
if (!open_sockets(is_daemon,port))
exit(1);
diff --git a/source3/smbwrapper/smbsh.c b/source3/smbwrapper/smbsh.c
index 37e29a94f9..ce54400488 100644
--- a/source3/smbwrapper/smbsh.c
+++ b/source3/smbwrapper/smbsh.c
@@ -42,9 +42,9 @@ int main(int argc, char *argv[])
int opt;
extern char *optarg;
extern int optind;
- extern FILE *dbf;
+ extern XFILE *dbf;
- dbf = stdout;
+ dbf = x_stdout;
smbw_setup_shared();
while ((opt = getopt(argc, argv, "W:U:R:d:P:l:hL:")) != EOF) {
diff --git a/source3/smbwrapper/smbw.c b/source3/smbwrapper/smbw.c
index dd78480f17..74a931587d 100644
--- a/source3/smbwrapper/smbw.c
+++ b/source3/smbwrapper/smbw.c
@@ -47,7 +47,7 @@ void smbw_init(void)
extern BOOL in_client;
static int initialised;
static pstring servicesf = CONFIGFILE;
- extern FILE *dbf;
+ extern XFILE *dbf;
char *p;
int eno;
pstring line;
@@ -62,7 +62,7 @@ void smbw_init(void)
DEBUGLEVEL = 0;
setup_logging("smbsh",True);
- dbf = stderr;
+ dbf = x_stderr;
if ((p=smbw_getshared("LOGFILE"))) {
dbf = sys_fopen(p, "a");
diff --git a/source3/torture/locktest.c b/source3/torture/locktest.c
index 0339576b11..bcae4fa924 100644
--- a/source3/torture/locktest.c
+++ b/source3/torture/locktest.c
@@ -545,7 +545,7 @@ static void usage(void)
char *share[NSERVERS];
extern char *optarg;
extern int optind;
- extern FILE *dbf;
+ extern XFILE *dbf;
int opt;
char *p;
int seed, server;
@@ -553,7 +553,7 @@ static void usage(void)
setlinebuf(stdout);
- dbf = stderr;
+ dbf = x_stderr;
if (argc < 3 || argv[1][0] == '-') {
usage();
diff --git a/source3/torture/locktest2.c b/source3/torture/locktest2.c
index ce988f0cc8..899310933f 100644
--- a/source3/torture/locktest2.c
+++ b/source3/torture/locktest2.c
@@ -533,7 +533,7 @@ static void usage(void)
char *share1, *share2, *nfspath1, *nfspath2;
extern char *optarg;
extern int optind;
- extern FILE *dbf;
+ extern XFILE *dbf;
int opt;
char *p;
int seed;
@@ -541,7 +541,7 @@ static void usage(void)
setlinebuf(stdout);
- dbf = stderr;
+ dbf = x_stderr;
if (argc < 5 || argv[1][0] == '-') {
usage();
diff --git a/source3/torture/masktest.c b/source3/torture/masktest.c
index 93caf5d017..0e054b4703 100644
--- a/source3/torture/masktest.c
+++ b/source3/torture/masktest.c
@@ -420,7 +420,7 @@ static void usage(void)
struct cli_state *cli;
extern char *optarg;
extern int optind;
- extern FILE *dbf;
+ extern XFILE *dbf;
int opt;
char *p;
int seed;
@@ -428,7 +428,7 @@ static void usage(void)
setlinebuf(stdout);
- dbf = stderr;
+ dbf = x_stderr;
if (argv[1][0] == '-' || argc < 2) {
usage();
diff --git a/source3/torture/rpctorture.c b/source3/torture/rpctorture.c
index 1708e9a860..5136a8e94b 100644
--- a/source3/torture/rpctorture.c
+++ b/source3/torture/rpctorture.c
@@ -229,7 +229,7 @@ enum client_action
{
char *pname = argv[0];
int opt;
- extern FILE *dbf;
+ extern XFILE *dbf;
extern char *optarg;
extern int optind;
static pstring servicesf = CONFIGFILE;
@@ -412,7 +412,7 @@ enum client_action
case 'E':
{
- dbf = stderr;
+ dbf = x_stderr;
break;
}
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 912abf07f2..292a4d61e0 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -3077,11 +3077,11 @@ static void usage(void)
int gotpass = 0;
extern char *optarg;
extern int optind;
- extern FILE *dbf;
+ extern XFILE *dbf;
static pstring servicesf = CONFIGFILE;
BOOL correct = True;
- dbf = stdout;
+ dbf = x_stdout;
#ifdef HAVE_SETBUFFER
setbuffer(stdout, NULL, 0);
diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c
index b26dbae417..59744a9315 100644
--- a/source3/utils/smbcacls.c
+++ b/source3/utils/smbcacls.c
@@ -802,7 +802,7 @@ You can string acls together with spaces, commas or newlines\n\
pstring filename;
extern char *optarg;
extern int optind;
- extern FILE *dbf;
+ extern XFILE *dbf;
int opt;
char *p;
static pstring servicesf = CONFIGFILE;
@@ -816,7 +816,7 @@ You can string acls together with spaces, commas or newlines\n\
setlinebuf(stdout);
- dbf = stderr;
+ dbf = x_stderr;
if (argc < 3 || argv[1][0] == '-') {
usage();
diff --git a/source3/utils/smbtree.c b/source3/utils/smbtree.c
index 41940d9a6c..75390965b3 100644
--- a/source3/utils/smbtree.c
+++ b/source3/utils/smbtree.c
@@ -325,7 +325,7 @@ static BOOL print_tree(struct user_auth_info *user_info)
{
extern char *optarg;
extern int optind;
- extern FILE *dbf;
+ extern XFILE *dbf;
int opt;
char *p;
pstring servicesf = CONFIGFILE;
@@ -336,7 +336,7 @@ static BOOL print_tree(struct user_auth_info *user_info)
setlinebuf(stdout);
- dbf = stderr;
+ dbf = x_stderr;
setup_logging(argv[0],True);
diff --git a/source3/utils/status.c b/source3/utils/status.c
index 91eca9f88f..7cbb1850de 100644
--- a/source3/utils/status.c
+++ b/source3/utils/status.c
@@ -45,7 +45,7 @@ struct session_record{
} *srecs;
extern int DEBUGLEVEL;
-extern FILE *dbf;
+extern XFILE *dbf;
static pstring Ucrit_username = ""; /* added by OH */
static pid_t Ucrit_pid[100]; /* Ugly !!! */ /* added by OH */
@@ -556,7 +556,7 @@ static int traverse_sessionid(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, vo
setup_logging(argv[0],True);
DEBUGLEVEL = 0;
- dbf = stderr;
+ dbf = x_stderr;
if (getuid() != geteuid()) {
d_printf("smbstatus should not be run setuid\n");
diff --git a/source3/utils/testparm.c b/source3/utils/testparm.c
index 28870fb272..e430fe414b 100644
--- a/source3/utils/testparm.c
+++ b/source3/utils/testparm.c
@@ -36,7 +36,7 @@
#include "smb.h"
/* these live in util.c */
-extern FILE *dbf;
+extern XFILE *dbf;
extern int DEBUGLEVEL;
/***********************************************
@@ -210,7 +210,7 @@ int main(int argc, char *argv[])
else if ((argc == 2) || (argc == 4))
pstrcpy(configfile,argv[optind]);
- dbf = stdout;
+ dbf = x_stdout;
DEBUGLEVEL = 2;
printf("Load smb config files from %s\n",configfile);
diff --git a/source3/utils/testprns.c b/source3/utils/testprns.c
index f8fdcd63a1..6a5b35db3b 100644
--- a/source3/utils/testprns.c
+++ b/source3/utils/testprns.c
@@ -35,7 +35,7 @@
#include "smb.h"
/* these live in util.c */
-extern FILE *dbf;
+extern XFILE *dbf;
extern int DEBUGLEVEL;
int main(int argc, char *argv[])
@@ -50,7 +50,7 @@ int main(int argc, char *argv[])
printf("Usage: testprns printername [printcapfile]\n");
else
{
- dbf = sys_fopen("test.log", "w");
+ dbf = x_fopen("test.log", O_WRONLY|O_CREAT|O_TRUNC, 0644);
if (dbf == NULL) {
printf("Unable to open logfile.\n");
} else {
@@ -62,7 +62,7 @@ int main(int argc, char *argv[])
printf("Printer name %s is not valid.\n", argv[1]);
else
printf("Printer name %s is valid.\n", argv[1]);
- fclose(dbf);
+ x_fclose(dbf);
}
}
return (0);
diff --git a/source3/web/cgi.c b/source3/web/cgi.c
index 651cd3d8c3..88f4d3f36f 100644
--- a/source3/web/cgi.c
+++ b/source3/web/cgi.c
@@ -149,9 +149,9 @@ void cgi_load_variables(FILE *f1)
len = content_length;
}
} else {
- fseek(f, 0, SEEK_END);
- len = ftell(f);
- fseek(f, 0, SEEK_SET);
+ struct stat st;
+ fstat(fileno(f), &st);
+ len = st.st_size;
}
diff --git a/source3/web/swat.c b/source3/web/swat.c
index f963c16ccf..8551c5e907 100644
--- a/source3/web/swat.c
+++ b/source3/web/swat.c
@@ -999,7 +999,7 @@ static void printers_page(void)
{
extern char *optarg;
extern int optind;
- extern FILE *dbf;
+ extern XFILE *dbf;
int opt;
char *page;
@@ -1016,8 +1016,8 @@ static void printers_page(void)
/* we don't want any SIGPIPE messages */
BlockSignals(True,SIGPIPE);
- dbf = sys_fopen("/dev/null", "w");
- if (!dbf) dbf = stderr;
+ dbf = x_fopen("/dev/null", O_WRONLY, 0);
+ if (!dbf) dbf = x_stderr;
/* we don't want stderr screwing us up */
close(2);