replaced stdio in many parts of samba with a XFILE. XFILE is a cut-down
authorAndrew Tridgell <tridge@samba.org>
Mon, 10 Sep 2001 11:08:57 +0000 (11:08 +0000)
committerAndrew Tridgell <tridge@samba.org>
Mon, 10 Sep 2001 11:08:57 +0000 (11:08 +0000)
replacemnt of stdio that doesn't suffer from the 8-bit filedescriptor
limit that we hit with nasty consequences on some systems

I would eventually prefer us to have a configure test to see if we need
to replace stdio, but for now this code needs to be tested widely so
I'm enabling it by default.
(This used to be commit 1af8bf34f1caa3e7ec312d8109c07d32a945a448)

28 files changed:
source3/Makefile.in
source3/aparser/parser.h
source3/client/client.c
source3/client/clitar.c
source3/client/smbmount.c
source3/include/includes.h
source3/include/smb_macros.h
source3/lib/cmd_interp.c
source3/lib/debug.c
source3/lib/readline.c
source3/lib/util.c
source3/nmbd/nmbd.c
source3/script/mkproto.awk
source3/smbd/server.c
source3/smbwrapper/smbsh.c
source3/smbwrapper/smbw.c
source3/torture/locktest.c
source3/torture/locktest2.c
source3/torture/masktest.c
source3/torture/rpctorture.c
source3/torture/torture.c
source3/utils/smbcacls.c
source3/utils/smbtree.c
source3/utils/status.c
source3/utils/testparm.c
source3/utils/testprns.c
source3/web/cgi.c
source3/web/swat.c

index 5f0ca9c16ff5628d752fc1fe87cf10d53ff9bb76..30036889b2d6513be168ba00a8cb823719e39e9e 100644 (file)
@@ -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 \
index 3d6540d8a70a982afab05653229f030074c9183b..319aeb5d13863f2ab37e9bfed2d8dbd50c03fe0b 100644 (file)
@@ -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
index 5612fc64b87781be2764548837ae75b2e9e06408..c9842335a9f98fa17bc82eecd7579932e80fc52a 100644 (file)
@@ -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;
 
index 8ce73f664556d3f4fe28d0a7e8fd25493aedbd73..6169c9af4606004f7341647e56011665aa7a008d 100644 (file)
@@ -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))
       {
index 71c7e298106af245bdd966db9d769577fcf39685..a87eb789ef76d185d535787f712911c3c727af5b 100644 (file)
@@ -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) {
index df0448bb9c119c96907832ebb5653cc5966aba81..1f97a2d7ed9903e24c27372cf2f12a743f254a12 100644 (file)
@@ -640,6 +640,7 @@ extern int errno;
 #include "messages.h"
 #include "util_list.h"
 #include "charset.h"
+#include "xfile.h"
 
 #include "util_getent.h"
 
index 315cb5e5ee7e1916e3ca74bc7cc42bf31fff1504..52649ffc395bb45070cf27780d8e96fcabd3bfda 100644 (file)
@@ -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)))
index 1d31d78b9477127c017bf9637d54a89ca7787720..fed3d65d6277deae8c3ad9674392518e2fb326db 100644 (file)
@@ -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;
                        }
 
index 4dbeda2f73914c763087e497295efe2ada1ed011..9eb490c27ea0861ca89410d88a486477e7807266 100644 (file)
@@ -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 */
 
 /* ************************************************************************** **
index 11d65a2b16dd497f032d16398969aa2dd3e11984..b03d37695e58635be4fa0765ee6136959f29498e 100644 (file)
@@ -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;
index 9b92e412d00a7109a6c653063f24c3ae270bc97a..d1d052d4a029a7d7422f302bfd66003d44887c7e 100644 (file)
@@ -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
 ****************************************************************************/
index 87c539371bea4693eb606a3658111e5adb3edd95..141d055281392fb5553c8a3c69f80a7d89d503fa 100644 (file)
@@ -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 */
 
index 200e4243bc457354454cd8cae9091173b835d017..097031590ea58040fa80c85a29f093b71b357fbd 100644 (file)
@@ -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;
   }
 
index 36c98300f0692ce596ea7b10bcc96bf71b9e6360..1dfff6cafa13d9fc6c24e75aa75f3dc7620b1804 100644 (file)
@@ -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);
 
index 37e29a94f9e769f0410cae999c0c4d105f692d4a..ce5440048845b1939560c8af4b3885ca6ded0ed9 100644 (file)
@@ -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) {
index dd78480f17d8b5b95954ef07b27415ba3aac8ae6..74a931587d9090f10d477f0014b8a82936302e0e 100644 (file)
@@ -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");
index 0339576b111a75f6fffec131511d29fe4a49c918..bcae4fa924325a16f67f16ae6b9140283e6cd8b6 100644 (file)
@@ -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();
index ce988f0cc8ac7eddeac5e5a8696082e8085d3025..899310933fc4453697ce62992182ad40d3708b1d 100644 (file)
@@ -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();
index 93caf5d017203b68f63940ae02251bd514f721a2..0e054b470315e8bf3fe9d7875242a3888d15719a 100644 (file)
@@ -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();
index 1708e9a860ab7226c8d24ce74d137df2d6e622a5..5136a8e94b3e74da5a80c57c3c872559fe5286ed 100644 (file)
@@ -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;
                        }
 
index 912abf07f250435e47048870e7fe4f5f69eb725e..292a4d61e07000ca407d357213abe31e700d3224 100644 (file)
@@ -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);
index b26dbae41756498a15b673d19983f32e4dad4eff..59744a931590c72ac2ba256c05610cc3026730d1 100644 (file)
@@ -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();
index 41940d9a6cad0f0059d1f0ad2588289b71417b76..75390965b31b4fdb31f72e3ce6ee0924672e27cf 100644 (file)
@@ -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);
 
index 91eca9f88f512390e3542a8b447c5a43921f8390..7cbb1850de00c18c337c5c20b11da0a6924fc998 100644 (file)
@@ -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");
index 28870fb2722e1634deb409f1a5925e5ffc3bc800..e430fe414ba18465fc7d38f57145336a8ccac14b 100644 (file)
@@ -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);
index f8fdcd63a1b4840c668e0d2f7ec2418d46bff2ce..6a5b35db3b58c85c9d742d0f1fa2a326b0dbc321 100644 (file)
@@ -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);
index 651cd3d8c3e95742aa661bac468388a86d4cd799..88f4d3f36fa97ecc2a8df4df71b091e5877dea8c 100644 (file)
@@ -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;
        }
 
 
index f963c16ccf83164491d8cdeb6d4f0cee9ace8ecc..8551c5e907ed8b58440dc5778abb40296a3233bb 100644 (file)
@@ -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);