Added the same open()/fopen()/creat()/mmap() -> sys_XXX calls.
authorJeremy Allison <jra@samba.org>
Tue, 17 Nov 1998 20:50:07 +0000 (20:50 +0000)
committerJeremy Allison <jra@samba.org>
Tue, 17 Nov 1998 20:50:07 +0000 (20:50 +0000)
Tidied up some of the mess (no other word for it). Still doesn't
compile cleanly. There are calls with incorrect parameters that
don't seem to be doing the right thing.

This code still needs surgery :-(.

Jeremy.
(This used to be commit 18ff93a9abbf68ee8c59c0af3e57c63e4a015dac)

56 files changed:
source3/client/client.c
source3/client/clitar.c
source3/configure
source3/configure.in
source3/groupdb/aliasdb.c
source3/groupdb/aliasfile.c
source3/groupdb/groupfile.c
source3/include/config.h.in
source3/include/proto.h
source3/lib/charset.c
source3/lib/debug.c
source3/lib/genrand.c
source3/lib/kanji.c
source3/lib/pidfile.c
source3/lib/smbrun.c
source3/lib/system.c
source3/lib/username.c
source3/lib/util.c
source3/lib/util_file.c
source3/lib/util_str.c
source3/libsmb/namequery.c
source3/locking/locking_slow.c
source3/locking/shmem.c
source3/nmbd/nmbd_namelistdb.c
source3/nmbd/nmbd_serverlistdb.c
source3/nmbd/nmbd_synclists.c
source3/nmbd/nmbd_winsserver.c
source3/param/params.c
source3/passdb/passdb.c
source3/passdb/smbpass.c
source3/passdb/smbpasschange.c
source3/passdb/smbpassfile.c
source3/passdb/smbpassgroup.c
source3/printing/pcap.c
source3/printing/printing.c
source3/rpc_server/srv_samr.c
source3/rpc_server/srv_sid.c
source3/script/installman.sh
source3/smbd/chgpasswd.c
source3/smbd/connection.c
source3/smbd/groupname.c
source3/smbd/ipc.c
source3/smbd/message.c
source3/smbd/open.c
source3/smbd/oplock.c
source3/smbd/password.c
source3/smbd/quotas.c
source3/smbwrapper/shared.c
source3/smbwrapper/smbw.c
source3/utils/make_printerdef.c
source3/utils/make_smbcodepage.c
source3/utils/status.c
source3/utils/testprns.c
source3/web/cgi.c
source3/web/statuspage.c
source3/web/swat.c

index 8356d99b7bd25babdaaf7fe71784f262032ca00c..c4c269293b34af87ec579dbc92e6bdec17fe70df 100644 (file)
@@ -496,7 +496,7 @@ static void do_get(char *rname,char *lname)
        if(!strcmp(lname,"-")) {
                handle = fileno(stdout);
        } else {
-               handle = open(lname,O_WRONLY|O_CREAT|O_TRUNC,0644);
+               handle = sys_open(lname,O_WRONLY|O_CREAT|O_TRUNC,0644);
                newhandle = True;
        }
        if (handle < 0) {
@@ -818,7 +818,7 @@ static void do_put(char *rname,char *lname)
                f = stdin;
                /* size of file is not known */
        } else {
-               f = fopen(lname,"r");
+               f = sys_fopen(lname,"r");
        }
 
        if (!f) {
@@ -982,7 +982,7 @@ static void cmd_mput(void)
                                 "/bin/ls %s > %s",p,tmpname);
                system(cmd);
 
-               f = fopen(tmpname,"r");
+               f = sys_fopen(tmpname,"r");
                if (!f) continue;
                
                while (!feof(f)) {
@@ -1787,7 +1787,7 @@ static void get_password_file(void)
                sscanf(p, "%d", &fd);
                close_it = False;
        } else if ((p = getenv("PASSWD_FILE")) != NULL) {
-               fd = open(p, O_RDONLY);
+               fd = sys_open(p, O_RDONLY, 0);
                pstrcpy(spec, p);
                if (fd < 0) {
                        fprintf(stderr, "Error opening PASSWD_FILE %s: %s\n",
index e7915d10660f87faa18cce6a7e834d5fc701e18c..a2b23817f5cb13c25aad9a8e3cea6b0b2b0615fb 100644 (file)
@@ -1539,7 +1539,7 @@ static int read_inclusion_file(char *filename)
 
   clipn = 0;
   buf[MAXPATHLEN] = '\0'; /* guarantee null-termination */
-  if ((inclusion = fopen(filename, "r")) == NULL) {
+  if ((inclusion = sys_fopen(filename, "r")) == NULL) {
     /* XXX It would be better to include a reason for failure, but without
      * autoconf, it's hard to use strerror, sys_errlist, etc.
      */
@@ -1823,8 +1823,8 @@ int tar_parseargs(int argc, char *argv[], char *Optarg, int Optind)
        }
        tarhandle=-1;
       } else
-    if ((tar_type=='x' && (tarhandle = open(argv[Optind], O_RDONLY)) == -1)
-       || (tar_type=='c' && (tarhandle=creat(argv[Optind], 0644)) < 0))
+    if ((tar_type=='x' && (tarhandle = sys_open(argv[Optind], O_RDONLY, 0)) == -1)
+       || (tar_type=='c' && (tarhandle=sys_creat(argv[Optind], 0644)) < 0))
       {
        DEBUG(0,("Error opening local file %s - %s\n",
                 argv[Optind], strerror(errno)));
index 0ec5ebb0b3a79345aa2a6d777edea916830e9b85..1d5779bf34ec23c6d57e02fbf3a702bb72ad2685 100755 (executable)
@@ -3769,7 +3769,7 @@ else
 fi
 done
 
-for ac_func in setuidx setgroups mktime rename ftruncate stat64 fstat64 lstat64
+for ac_func in setuidx setgroups mktime rename ftruncate stat64 fstat64 lstat64 fopen64
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
 echo "configure:3776: checking for $ac_func" >&5
@@ -3934,7 +3934,7 @@ else
 fi
 done
 
-for ac_func in srandom random srand rand setenv
+for ac_func in srandom random srand rand setenv mmap64
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
 echo "configure:3941: checking for $ac_func" >&5
index 55fe56fe9e3b979d1c6a5ceefaa71a0e1b9eb2ff..f555087ddfd999dbb9e94d43bf7eaddd4f092441 100644 (file)
@@ -168,10 +168,10 @@ AC_CHECK_FUNCS(fstat strchr utime utimes getrlimit fsync execl bzero memset)
 AC_CHECK_FUNCS(memmove vsnprintf snprintf setsid glob strpbrk pipe crypt16 getauthuid)
 AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction innetgr)
 AC_CHECK_FUNCS(initgroups select rdchk getgrnam pathconf putprpwnam)
-AC_CHECK_FUNCS(setuidx setgroups mktime rename ftruncate stat64 fstat64 lstat64)
+AC_CHECK_FUNCS(setuidx setgroups mktime rename ftruncate stat64 fstat64 lstat64 fopen64)
 AC_CHECK_FUNCS(set_auth_parameters atexit grantpt getspnam dup2 lseek64 ftruncate64)
 AC_CHECK_FUNCS(fseek64 ftell64 bigcrypt getprpwnam setluid yp_get_default_domain getpwanam)
-AC_CHECK_FUNCS(srandom random srand rand setenv)
+AC_CHECK_FUNCS(srandom random srand rand setenv mmap64)
 # syscall() is needed for smbwrapper.
 AC_CHECK_FUNCS(syscall)
 
index e5e6ebfa53f179e0c527dd33602609eff26fee8c..03e0a6e11ae612a2e637466a5948c6499df7bc8d 100644 (file)
@@ -191,14 +191,14 @@ static BOOL user_is_member(char *user_name, LOCAL_GRP_MEMBER *mem, int num_mem)
  *************************************************************************/
 BOOL iterate_getuseraliasnam(char *user_name, LOCAL_GRP **alss, int *num_alss)
 {
-       LOCAL_GRP *als;
+       LOCAL_GRP *als = NULL;
        LOCAL_GRP_MEMBER *mem = NULL;
        int num_mem = 0;
        void *fp = NULL;
 
        DEBUG(10, ("search for useralias by name: %s\n", user_name));
 
-       if (user_name == NULL || als == NULL || num_alss == NULL)
+       if (user_name == NULL || alss == NULL || num_alss == NULL)
        {
                return False;
        }
@@ -254,12 +254,12 @@ BOOL iterate_getuseraliasnam(char *user_name, LOCAL_GRP **alss, int *num_alss)
  *************************************************************************/
 BOOL enumdomaliases(LOCAL_GRP **alss, int *num_alss)
 {
-       LOCAL_GRP *als;
+       LOCAL_GRP *als = NULL;
        void *fp = NULL;
 
        DEBUG(10, ("enum user aliases\n"));
 
-       if (als == NULL || num_alss == NULL)
+       if (alss == NULL || num_alss == NULL)
        {
                return False;
        }
index fc87b47c47d02900c7fa7123375506605fbc1b9a..01166bcc1ff5bb43cd31cdc575c0c3689a0dcf36 100644 (file)
@@ -176,14 +176,13 @@ static LOCAL_GRP *getalsfilepwent(void *vp, LOCAL_GRP_MEMBER **mem, int *num_mem
 
        pstring linebuf;
        char  *p;
-       size_t            linebuf_len;
 
        aldb_init_als(&al_buf);
 
        /*
         * Scan the file, a line at a time and check if the name matches.
         */
-       while ((linebuf_len = getfileline(vp, linebuf, sizeof(linebuf))) > 0)
+       while (getfileline(vp, linebuf, sizeof(linebuf)) > 0)
        {
                /* get alias name */
 
index 8044071391fa057a01f3cf8d668d0389be4d9b0f..09939de71e0190ae50bc55227b4eee792b651127 100644 (file)
@@ -135,7 +135,7 @@ static char *get_group_members(char *p, int *num_mem, DOMAIN_GRP_MEMBER **member
                uint8 type;
                BOOL found = False;
 
-               if (isdigit(name))
+               if (isdigit(name[0]))
                {
                        uint32 rid = get_number(name);
                        sid_copy(&sid, &global_sam_sid);
@@ -180,14 +180,13 @@ static DOMAIN_GRP *getgrpfilepwent(void *vp, DOMAIN_GRP_MEMBER **mem, int *num_m
 
        pstring linebuf;
        char  *p;
-       size_t            linebuf_len;
 
        gpdb_init_grp(&gp_buf);
 
        /*
         * Scan the file, a line at a time and check if the name matches.
         */
-       while ((linebuf_len = getfileline(vp, linebuf, sizeof(linebuf))) > 0)
+       while (getfileline(vp, linebuf, sizeof(linebuf)) > 0)
        {
                /* get group name */
 
index 49379cfe9c2dca2822f15500f612ed939e8d0eda..c5c761ede393f8d06aeb3ad5359c2d22212c8ca0 100644 (file)
 /* Define if you have the execl function.  */
 #undef HAVE_EXECL
 
+/* Define if you have the fopen64 function.  */
+#undef HAVE_FOPEN64
+
 /* Define if you have the fseek64 function.  */
 #undef HAVE_FSEEK64
 
 /* Define if you have the mktime function.  */
 #undef HAVE_MKTIME
 
+/* Define if you have the mmap64 function.  */
+#undef HAVE_MMAP64
+
 /* Define if you have the open64 function.  */
 #undef HAVE_OPEN64
 
index 329903f787e8f257746f1ae667d5e8f237164654..d68853b5e6d40efb15ee7acce94f09af9453050d 100644 (file)
@@ -198,6 +198,10 @@ int sys_ftruncate(int fd, SMB_OFF_T offset);
 SMB_OFF_T sys_lseek(int fd, SMB_OFF_T offset, int whence);
 int sys_fseek(FILE *fp, SMB_OFF_T offset, int whence);
 SMB_OFF_T sys_ftell(FILE *fp);
+int sys_creat(const char *path, mode_t mode);
+int sys_open(const char *path, int oflag, mode_t mode);
+FILE *sys_fopen(const char *path, const char *type);
+void *sys_mmap(void *addr, size_t len, int prot, int flags, int fd, SMB_OFF_T offset);
 int dos_unlink(char *fname);
 int dos_open(char *fname,int flags,mode_t mode);
 DIR *dos_opendir(char *dname);
@@ -383,35 +387,35 @@ char *client_addr(int fd);
 /*The following definitions come from  lib/util_str.c  */
 
 void set_first_token(char *ptr);
-BOOL next_token(char **ptr,char *buff,char *sep, int bufsize);
+BOOL next_token(char **ptr,char *buff,char *sep, size_t bufsize);
 char **toktocliplist(int *ctok, char *sep);
 int StrCaseCmp(const char *s, const char *t);
-int StrnCaseCmp(char *s, char *t, int n);
+int StrnCaseCmp(const char *s, const char *t, size_t n);
 BOOL strequal(const char *s1, const char *s2);
-BOOL strnequal(char *s1,char *s2,int n);
-BOOL strcsequal(char *s1,char *s2);
+BOOL strnequal(const char *s1,const char *s2,size_t n);
+BOOL strcsequal(const char *s1,const char *s2);
 void strlower(char *s);
 void strupper(char *s);
 void strnorm(char *s);
 BOOL strisnormal(char *s);
 void string_replace(char *s,char oldc,char newc);
-char *skip_string(char *buf,int n);
-size_t str_charnum(char *s);
-BOOL trim_string(char *s,char *front,char *back);
-BOOL strhasupper(char *s);
-BOOL strhaslower(char *s);
-int count_chars(char *s,char c);
-char *safe_strcpy(char *dest,const char *src, int maxlength);
-char *safe_strcat(char *dest, char *src, int maxlength);
-char *StrCpy(char *dest,char *src);
-char *StrnCpy(char *dest,const char *src,int n);
-char *strncpyn(char *dest, const char *src,int n, char c);
-int strhex_to_str(char *p, int len, const char *strhex);
+char *skip_string(const char *buf,size_t n);
+size_t str_charnum(const char *s);
+BOOL trim_string(char *s,const char *front,const char *back);
+BOOL strhasupper(const char *s);
+BOOL strhaslower(const char *s);
+size_t count_chars(const char *s,char c);
+char *safe_strcpy(char *dest,const char *src, size_t maxlength);
+char *safe_strcat(char *dest, const char *src, size_t maxlength);
+char *StrCpy(char *dest,const char *src);
+char *StrnCpy(char *dest,const char *src,size_t n);
+char *strncpyn(char *dest, const char *src,size_t n, char c);
+size_t strhex_to_str(char *p, size_t len, const char *strhex);
 BOOL in_list(char *s,char *list,BOOL casesensitive);
-BOOL string_init(char **dest,char *src);
+BOOL string_init(char **dest,const char *src);
 void string_free(char **s);
-BOOL string_set(char **dest,char *src);
-BOOL string_sub(char *s,char *pattern,char *insert);
+BOOL string_set(char **dest,const char *src);
+BOOL string_sub(char *s,const char *pattern,const char *insert);
 void split_at_last_component(char *path, char *front, char sep, char *back);
 
 /*The following definitions come from  lib/util_unistr.c  */
@@ -1266,8 +1270,8 @@ struct sam_disp_info *pwdb_sam_to_dispinfo(struct sam_passwd *user);
 struct smb_passwd *pwdb_sam_to_smb(struct sam_passwd *user);
 struct sam_passwd *pwdb_smb_to_sam(struct smb_passwd *user);
 char *pwdb_encode_acct_ctrl(uint16 acct_ctrl, size_t length);
-uint16 pwdb_decode_acct_ctrl(char *p);
-time_t pwdb_get_last_set_time(char *p);
+uint16 pwdb_decode_acct_ctrl(const char *p);
+time_t pwdb_get_last_set_time(const char *p);
 void pwdb_set_logon_time(char *p, int max_len, time_t t);
 void pwdb_set_logoff_time(char *p, int max_len, time_t t);
 void pwdb_set_kickoff_time(char *p, int max_len, time_t t);
index 5bf3bfbe30fec6780c6d10a5615d04cced10031c..fc2924a155ab8e398485bcfa8ca01072785a7da9 100644 (file)
@@ -235,7 +235,7 @@ code page file (size=%d).\n", codepage_file_name, (int)size));
      is held in little endian format.
    */
 
-  if((fp = fopen( codepage_file_name, "r")) == NULL)
+  if((fp = sys_fopen( codepage_file_name, "r")) == NULL)
   {
     DEBUG(0,("load_client_codepage: cannot open file %s. Error was %s\n",
               codepage_file_name, strerror(errno)));
index 619a917747ef8a3557198ebb718f5df79e6fe53c..3a90da2f3d2a9c41d027947277cf7100e671f8ac 100644 (file)
@@ -224,9 +224,9 @@ void reopen_logs( void )
       if( dbf )
         (void)fclose( dbf );
       if( append_log )
-        dbf = fopen( debugf, "a" );
+        dbf = sys_fopen( debugf, "a" );
       else
-        dbf = fopen( debugf, "w" );
+        dbf = sys_fopen( debugf, "w" );
       /* Fix from klausr@ITAP.Physik.Uni-Stuttgart.De
        * to fix problem where smbd's that generate less
        * than 100 messages keep growing the log.
@@ -331,9 +331,9 @@ va_dcl
       mode_t oldumask = umask( 022 );
 
       if( append_log )
-        dbf = fopen( debugf, "a" );
+        dbf = sys_fopen( debugf, "a" );
       else
-        dbf = fopen( debugf, "w" );
+        dbf = sys_fopen( debugf, "w" );
       (void)umask( oldumask );
       if( dbf )
         {
index bb1922e4f5c795bafda8c11e0f415d7534e6589b..8b05b02f943d83bc274bc3454747a36a15477c61 100644 (file)
@@ -36,7 +36,7 @@ static void do_filehash(char *fname, unsigned char *hash)
        unsigned char tmp_md4[16];
        int fd, n;
 
-       fd = open(fname,O_RDONLY);
+       fd = sys_open(fname,O_RDONLY,0);
        if (fd == -1) return;
 
        while ((n = read(fd, (char *)buf, sizeof(buf))) > 0) {
@@ -121,7 +121,7 @@ static uint32 do_reseed(unsigned char *md4_outbuf)
 
   memset(md4_inbuf, '\0', sizeof(md4_inbuf));
 
-  fd = open( "/dev/random", O_RDONLY);
+  fd = sys_open( "/dev/random", O_RDONLY,0);
   if(fd >= 0) {
     /* 
      * We can use /dev/random !
index 565e8d852f62adf43d79aa8bf939097cb2d8a450..871a4a059c897a707ce13495c5e98b843b16ae1d 100644 (file)
@@ -54,12 +54,12 @@ char *(*multibyte_strtok)(char *, const char *) = (char *(*)(char *, const char
  * charcnv.c.
  */
 
-static int skip_non_multibyte_char(char);
+static size_t skip_non_multibyte_char(char);
 static BOOL not_multibyte_char_1(char);
 
 char *(*_dos_to_unix)(char *, BOOL) = dos2unix_format;
 char *(*_unix_to_dos)(char *, BOOL) = unix2dos_format;
-int (*_skip_multibyte_char)(char) = skip_non_multibyte_char;
+size_t (*_skip_multibyte_char)(char) = skip_non_multibyte_char;
 BOOL (*is_multibyte_char_1)(char) = not_multibyte_char_1;
 
 #else /* KANJI */
@@ -70,12 +70,12 @@ BOOL (*is_multibyte_char_1)(char) = not_multibyte_char_1;
  */
 
 static char *sj_to_sj(char *from, BOOL overwrite);
-static int skip_kanji_multibyte_char(char);
+static size_t skip_kanji_multibyte_char(char);
 static BOOL is_kanji_multibyte_char_1(char);
 
 char *(*_dos_to_unix)(char *, BOOL) = sj_to_sj;
 char *(*_unix_to_dos)(char *, BOOL) = sj_to_sj;
-int (*_skip_multibyte_char)(char) = skip_kanji_multibyte_char;
+size_t (*_skip_multibyte_char)(char) = skip_kanji_multibyte_char;
 int (*is_multibyte_char_1)(char) = is_kanji_multibyte_char_1;
 
 #endif /* KANJI */
@@ -198,7 +198,7 @@ static const char *sj_strrchr(const char *s, int c)
  Kanji multibyte char skip function.
 *******************************************************************/
    
-static int skip_kanji_multibyte_char(char c)
+static size_t skip_kanji_multibyte_char(char c)
 {
   if(is_shift_jis(c)) {
     return 2;
@@ -364,7 +364,7 @@ static const char *generic_multibyte_strrchr(const char *s, int c)
  Generic multibyte char skip function.
 *******************************************************************/
 
-static int skip_generic_multibyte_char(char c)
+static size_t skip_generic_multibyte_char(char c)
 {
   if( (*is_multibyte_char_1)(c)) {
     return 2;
@@ -1143,7 +1143,7 @@ void interpret_coding_system(char *str)
  Non multibyte char function.
 *******************************************************************/
    
-static int skip_non_multibyte_char(char c)
+static size_t skip_non_multibyte_char(char c)
 {
   return 0;
 }
index 7e98438dba73c11f9ad304ceb55ef1f3f5a01692..52a3be875fc7df2b0ae0bf961fa67ec413a2c7f1 100644 (file)
@@ -38,7 +38,7 @@ pid_t pidfile_pid(char *name)
 
        slprintf(pidFile, sizeof(pidFile)-1, "%s/%s.pid", lp_lockdir(), name);
 
-       f = fopen(pidFile, "r");
+       f = sys_fopen(pidFile, "r");
        if (!f) {
                return 0;
        }
@@ -71,7 +71,7 @@ void pidfile_create(char *name)
       exit(1);
     }
 
-       fd = open(pidFile, O_NONBLOCK | O_CREAT | O_WRONLY, 0644);
+       fd = sys_open(pidFile, O_NONBLOCK | O_CREAT | O_WRONLY, 0644);
        if (fd < 0) {
                DEBUG(0,("ERROR: can't open %s: Error was %s\n", pidFile, 
                         strerror(errno)));
index 86d7cf9e03f697d329e6b434368cb840e3f5032b..da7632a67a9d66461b5911499dd394615334d171 100644 (file)
@@ -58,7 +58,7 @@ static BOOL setup_stdout_file(char *outfile,BOOL shared)
       flags = O_RDWR;
   }
   /* now create the file */
-  fd = open(outfile,flags,mode);
+  fd = sys_open(outfile,flags,mode);
 
   if (fd == -1) return False;
 
index deca7e1b6a9b3040bd1b319493f373653df3de2c..d07df3faf05588032ff302ee0b9e3828c257e173 100644 (file)
@@ -230,6 +230,62 @@ SMB_OFF_T sys_ftell(FILE *fp)
 #endif
 }
 
+/*******************************************************************
+ A creat() wrapper that will deal with 64 bit filesizes.
+********************************************************************/
+
+int sys_creat(const char *path, mode_t mode)
+{
+#if defined(HAVE_CREAT64)
+  return creat64(path, mode);
+#else
+  /*
+   * If creat64 isn't defined then ensure we call a potential open64.
+   * JRA.
+   */
+  return sys_open(path, O_WRONLY | O_CREAT | O_TRUNC, mode);
+#endif
+}
+
+/*******************************************************************
+ An open() wrapper that will deal with 64 bit filesizes.
+********************************************************************/
+
+int sys_open(const char *path, int oflag, mode_t mode)
+{
+#if defined(HAVE_OPEN64)
+  return open64(path, oflag, mode);
+#else
+  return open(path, oflag, mode);
+#endif
+}
+
+/*******************************************************************
+ An fopen() wrapper that will deal with 64 bit filesizes.
+********************************************************************/
+
+FILE *sys_fopen(const char *path, const char *type)
+{
+#if defined(HAVE_FOPEN64)
+  return fopen64(path, type);
+#else
+  return fopen(path, type);
+#endif
+}
+
+/*******************************************************************
+ An mmap() wrapper that will deal with 64 bit filesizes.
+********************************************************************/
+
+void *sys_mmap(void *addr, size_t len, int prot, int flags, int fd, SMB_OFF_T offset)
+{
+#if defined(LARGE_SMB_OFF_T) && defined(HAVE_MMAP64)
+  return mmap64(addr, len, prot, flags, fd, offset);
+#else
+  return mmap(addr, len, prot, flags, fd, offset);
+#endif
+}
+
 /*******************************************************************
 just a unlink wrapper that calls dos_to_unix.
 ********************************************************************/
@@ -244,7 +300,7 @@ a simple open() wrapper that calls dos_to_unix.
 ********************************************************************/
 int dos_open(char *fname,int flags,mode_t mode)
 {
-  return(open(dos_to_unix(fname,False),flags,mode));
+  return(sys_open(dos_to_unix(fname,False),flags,mode));
 }
 
 
@@ -345,10 +401,10 @@ static int copy_reg(char *source, const char *dest)
   if (unlink (dest) && errno != ENOENT)
     return 1;
 
-  if((ifd = open (source, O_RDONLY, 0)) < 0)
+  if((ifd = sys_open (source, O_RDONLY, 0)) < 0)
     return 1;
 
-  if((ofd = open (dest, O_WRONLY | O_CREAT | O_TRUNC, 0600)) < 0 )
+  if((ofd = sys_open (dest, O_WRONLY | O_CREAT | O_TRUNC, 0600)) < 0 )
   {
     close (ifd);
     return 1;
index f56f7efce2efc0ade7ac071bb3a8e29a8c7075b7..f04314ab36d75b12ae8e16b476cd115b408dbae5 100644 (file)
@@ -80,7 +80,7 @@ BOOL map_username(char *user)
     return True;
   }
   
-  f = fopen(mapfile,"r");
+  f = sys_fopen(mapfile,"r");
   if (!f) {
     DEBUG(0,("can't open username map %s\n",mapfile));
     return False;
index df3faa569a565305f2ab47a1d82de245d4340396..7247e95c6449160df496a32b7d0a78c24527d10c 100644 (file)
@@ -1059,8 +1059,8 @@ void close_low_fds(void)
   /* try and use up these file descriptors, so silly
      library routines writing to stdout etc won't cause havoc */
   for (i=0;i<3;i++) {
-    fd = open("/dev/null",O_RDWR,0);
-    if (fd < 0) fd = open("/dev/null",O_WRONLY,0);
+    fd = sys_open("/dev/null",O_RDWR,0);
+    if (fd < 0) fd = sys_open("/dev/null",O_WRONLY,0);
     if (fd < 0) {
       DEBUG(0,("Can't open /dev/null\n"));
       return;
@@ -1705,7 +1705,7 @@ void become_daemon(void)
        setsid();
 #elif defined(TIOCNOTTY)
        {
-               int i = open("/dev/tty", O_RDWR);
+               int i = sys_open("/dev/tty", O_RDWR, 0);
                if (i != -1) {
                        ioctl(i, (int) TIOCNOTTY, (char *)0);      
                        close(i);
index 0d6e77b010db4cae303b03a5f14f18bdf72e14a0..faceed1dbd51a6cbca49a8c50fa41d60e9a72eed 100644 (file)
@@ -125,7 +125,7 @@ void *startfilepwent(char *pfile, char *s_readbuf, int bufsize,
   }
   DEBUG(10, ("startfilepwent: opening file %s\n", pfile));
 
-  fp = fopen(pfile, update ? "r+b" : "rb");
+  fp = sys_fopen(pfile, update ? "r+b" : "rb");
 
   if (fp == NULL) {
     DEBUG(0, ("startfilepwent: unable to open file %s\n", pfile));
index 02fa892d7b2d3734165ec500d651f57b43e8f091..c943a854cfa1900d0e73af543f864b6a4251d1be 100644 (file)
@@ -36,11 +36,11 @@ void set_first_token(char *ptr)
 Based on a routine by GJC@VILLAGE.COM. 
 Extensively modified by Andrew.Tridgell@anu.edu.au
 ****************************************************************************/
-BOOL next_token(char **ptr,char *buff,char *sep, int bufsize)
+BOOL next_token(char **ptr,char *buff,char *sep, size_t bufsize)
 {
   char *s;
   BOOL quoted;
-  int len=1;
+  size_t len=1;
 
   if (!ptr) ptr = &last_ptr;
   if (!ptr) return(False);
@@ -188,7 +188,7 @@ int StrCaseCmp(const char *s, const char *t)
 /*******************************************************************
   case insensitive string compararison, length limited
 ********************************************************************/
-int StrnCaseCmp(char *s, char *t, int n)
+int StrnCaseCmp(const char *s, const char *t, size_t n)
 {
   /* compare until we run out of string, either t or s, or chars */
   /* We *must* use toupper rather than tolower here due to the
@@ -283,7 +283,7 @@ BOOL strequal(const char *s1, const char *s2)
 /*******************************************************************
   compare 2 strings up to and including the nth char.
   ******************************************************************/
-BOOL strnequal(char *s1,char *s2,int n)
+BOOL strnequal(const char *s1,const char *s2,size_t n)
 {
   if (s1 == s2) return(True);
   if (!s1 || !s2 || !n) return(False);
@@ -294,7 +294,7 @@ BOOL strnequal(char *s1,char *s2,int n)
 /*******************************************************************
   compare 2 strings (case sensitive)
 ********************************************************************/
-BOOL strcsequal(char *s1,char *s2)
+BOOL strcsequal(const char *s1,const char *s2)
 {
   if (s1 == s2) return(True);
   if (!s1 || !s2) return(False);
@@ -343,7 +343,7 @@ void strlower(char *s)
     else
 #endif /* KANJI_WIN95_COMPATIBILITY */
     {
-      int skip = skip_multibyte_char( *s );
+      size_t skip = skip_multibyte_char( *s );
       if( skip != 0 )
         s += skip;
       else
@@ -396,7 +396,7 @@ void strupper(char *s)
     else
 #endif /* KANJI_WIN95_COMPATIBILITY */
     {
-      int skip = skip_multibyte_char( *s );
+      size_t skip = skip_multibyte_char( *s );
       if( skip != 0 )
         s += skip;
       else
@@ -439,7 +439,7 @@ BOOL strisnormal(char *s)
 ****************************************************************************/
 void string_replace(char *s,char oldc,char newc)
 {
-  int skip;
+  size_t skip;
   while (*s)
   {
     skip = skip_multibyte_char( *s );
@@ -458,11 +458,11 @@ void string_replace(char *s,char oldc,char newc)
 /*******************************************************************
 skip past some strings in a buffer
 ********************************************************************/
-char *skip_string(char *buf,int n)
+char *skip_string(const char *buf,size_t n)
 {
   while (n--)
     buf += strlen(buf) + 1;
-  return(buf);
+  return((char *)buf);
 }
 
 /*******************************************************************
@@ -472,7 +472,7 @@ char *skip_string(char *buf,int n)
  16.oct.98, jdblair@cobaltnet.com.
 ********************************************************************/
 
-size_t str_charnum(char *s)
+size_t str_charnum(const char *s)
 {
   size_t len = 0;
   
@@ -488,7 +488,7 @@ size_t str_charnum(char *s)
 trim the specified elements off the front and back of a string
 ********************************************************************/
 
-BOOL trim_string(char *s,char *front,char *back)
+BOOL trim_string(char *s,const char *front,const char *back)
 {
   BOOL ret = False;
   size_t front_len = (front && *front) ? strlen(front) : 0;
@@ -584,7 +584,7 @@ BOOL trim_string(char *s,char *front,char *back)
 /****************************************************************************
 does a string have any uppercase chars in it?
 ****************************************************************************/
-BOOL strhasupper(char *s)
+BOOL strhasupper(const char *s)
 {
   while (*s) 
   {
@@ -615,7 +615,7 @@ BOOL strhasupper(char *s)
     else
 #endif /* KANJI_WIN95_COMPATIBILITY */
     {
-      int skip = skip_multibyte_char( *s );
+      size_t skip = skip_multibyte_char( *s );
       if( skip != 0 )
         s += skip;
       else {
@@ -631,7 +631,7 @@ BOOL strhasupper(char *s)
 /****************************************************************************
 does a string have any lowercase chars in it?
 ****************************************************************************/
-BOOL strhaslower(char *s)
+BOOL strhaslower(const char *s)
 {
   while (*s) 
   {
@@ -670,7 +670,7 @@ BOOL strhaslower(char *s)
     else
 #endif /* KANJI_WIN95_COMPATIBILITY */
     {
-      int skip = skip_multibyte_char( *s );
+      size_t skip = skip_multibyte_char( *s );
       if( skip != 0 )
         s += skip;
       else {
@@ -686,9 +686,9 @@ BOOL strhaslower(char *s)
 /****************************************************************************
 find the number of chars in a string
 ****************************************************************************/
-int count_chars(char *s,char c)
+size_t count_chars(const char *s,char c)
 {
-  int count=0;
+  size_t count=0;
 
 #if !defined(KANJI_WIN95_COMPATIBILITY)
   /*
@@ -720,7 +720,7 @@ int count_chars(char *s,char c)
   {
     while (*s) 
     {
-      int skip = skip_multibyte_char( *s );
+      size_t skip = skip_multibyte_char( *s );
       if( skip != 0 )
         s += skip;
       else {
@@ -739,9 +739,9 @@ int count_chars(char *s,char c)
 safe string copy into a known length string. maxlength does not
 include the terminating zero.
 ********************************************************************/
-char *safe_strcpy(char *dest,const char *src, int maxlength)
+char *safe_strcpy(char *dest,const char *src, size_t maxlength)
 {
-    int len;
+    size_t len;
 
     if (!dest) {
         DEBUG(0,("ERROR: NULL dest in safe_strcpy\n"));
@@ -770,9 +770,9 @@ char *safe_strcpy(char *dest,const char *src, int maxlength)
 safe string cat into a string. maxlength does not
 include the terminating zero.
 ********************************************************************/
-char *safe_strcat(char *dest, char *src, int maxlength)
+char *safe_strcat(char *dest, const char *src, size_t maxlength)
 {
-    int src_len, dest_len;
+    size_t src_len, dest_len;
 
     if (!dest) {
         DEBUG(0,("ERROR: NULL dest in safe_strcat\n"));
@@ -800,7 +800,7 @@ char *safe_strcat(char *dest, char *src, int maxlength)
 /****************************************************************************
 this is a safer strcpy(), meant to prevent core dumps when nasty things happen
 ****************************************************************************/
-char *StrCpy(char *dest,char *src)
+char *StrCpy(char *dest,const char *src)
 {
   char *d = dest;
 
@@ -819,7 +819,7 @@ char *StrCpy(char *dest,char *src)
 /****************************************************************************
 like strncpy but always null terminates. Make sure there is room!
 ****************************************************************************/
-char *StrnCpy(char *dest,const char *src,int n)
+char *StrnCpy(char *dest,const char *src,size_t n)
 {
   char *d = dest;
   if (!dest) return(NULL);
@@ -837,10 +837,10 @@ char *StrnCpy(char *dest,const char *src,int n)
 like strncpy but copies up to the character marker.  always null terminates.
 returns a pointer to the character marker in the source string (src).
 ****************************************************************************/
-char *strncpyn(char *dest, const char *src,int n, char c)
+char *strncpyn(char *dest, const char *src,size_t n, char c)
 {
        char *p;
-       int str_len;
+       size_t str_len;
 
        p = strchr(src, c);
        if (p == NULL)
@@ -866,10 +866,10 @@ char *strncpyn(char *dest, const char *src,int n, char c)
  valid examples: "0A5D15"; "0x15, 0x49, 0xa2"; "59\ta9\te3\n"
 
 **************************************************************/
-int strhex_to_str(char *p, int len, const char *strhex)
+size_t strhex_to_str(char *p, size_t len, const char *strhex)
 {
-       int i;
-       int num_chars = 0;
+       size_t i;
+       size_t num_chars = 0;
        unsigned char   lonybble, hinybble;
        char           *hexchars = "0123456789ABCDEF";
        char           *p1 = NULL, *p2 = NULL;
@@ -935,9 +935,9 @@ static char *null_string = NULL;
 /****************************************************************************
 set a string value, allocing the space for the string
 ****************************************************************************/
-BOOL string_init(char **dest,char *src)
+BOOL string_init(char **dest,const char *src)
 {
-  int l;
+  size_t l;
   if (!src)     
     src = "";
 
@@ -983,7 +983,7 @@ void string_free(char **s)
 set a string value, allocing the space for the string, and deallocating any 
 existing space
 ****************************************************************************/
-BOOL string_set(char **dest,char *src)
+BOOL string_set(char **dest,const char *src)
 {
   string_free(dest);
 
@@ -999,11 +999,11 @@ insert. It may do multiple replacements.
 
 return True if a substitution was done.
 ****************************************************************************/
-BOOL string_sub(char *s,char *pattern,char *insert)
+BOOL string_sub(char *s,const char *pattern,const char *insert)
 {
   BOOL ret = False;
   char *p;
-  int ls,lp,li;
+  size_t ls,lp,li;
 
   if (!insert || !pattern || !s) return(False);
 
index 1398f7bc492fbb83bebfd1fc3295fb212c1a81b2..149b977746c9ef130b40ec3b53208967f55e10e4 100644 (file)
@@ -332,7 +332,7 @@ struct in_addr *name_query(int fd,const char *name,int name_type, BOOL bcast,BOO
 
 FILE *startlmhosts(char *fname)
 {
-  FILE *fp = fopen(fname,"r");
+  FILE *fp = sys_fopen(fname,"r");
   if (!fp) {
     DEBUG(4,("startlmhosts: Can't open lmhosts file %s. Error was %s\n",
              fname, strerror(errno)));
index f1e0fa214965bcaac6ebe5582a6868556e35e4ee..7c273552242b72d504cc1863ff9bcdb2c0df8a61 100644 (file)
@@ -165,8 +165,7 @@ static BOOL slow_lock_share_entry(connection_struct *conn,
     {
       SMB_STRUCT_STAT dummy_stat;
 
-      fd = (int)open(fname,read_only?O_RDONLY:(O_RDWR|O_CREAT),
-                    SHARE_FILE_MODE);
+      fd = sys_open(fname,read_only?O_RDONLY:(O_RDWR|O_CREAT), SHARE_FILE_MODE);
 
       if(fd < 0)
       {
@@ -1008,7 +1007,7 @@ static int slow_share_forall(void (*fn)(share_mode_entry *, char *))
                pstrcat(lname,"/");
                pstrcat(lname,s);
        
-               fd = open(lname,read_only?O_RDONLY:O_RDWR,0);
+               fd = sys_open(lname,read_only?O_RDONLY:O_RDWR,0);
                if (fd < 0) {
                        continue;
                }
index 2a4e4de129a2c7ecaf19b13ce5a8b4c0f9d76edb..435c0d4c7894f59f9df69eee77ecb0f64e67966f 100644 (file)
@@ -318,7 +318,7 @@ static BOOL smb_shm_register_process(char *processreg_file, pid_t pid, BOOL *oth
   SMB_OFF_T free_slot = -1;
   SMB_OFF_T erased_slot;   
    
-  smb_shm_processes_fd = open(processreg_file, 
+  smb_shm_processes_fd = sys_open(processreg_file, 
                               read_only?O_RDONLY:(O_RDWR|O_CREAT), 
                               SHM_FILE_MODE);
 
@@ -429,7 +429,7 @@ static BOOL smb_shm_unregister_process(char *processreg_file, pid_t pid)
    BOOL found = False;
    
    
-   smb_shm_processes_fd = open(processreg_file, O_RDWR);
+   smb_shm_processes_fd = sys_open(processreg_file, O_RDWR, 0);
    if ( smb_shm_processes_fd < 0 )
    {
       DEBUG(0,("ERROR smb_shm_unregister_process : processreg_file open failed with code %s\n",strerror(errno)));
@@ -818,7 +818,7 @@ struct shmem_ops *smb_shm_open(int ronly)
   DEBUG(5,("smb_shm_open : using shmem file %s to be of size %.0f\n",
         file_name,(double)size));
 
-  smb_shm_fd = open(file_name, read_only?O_RDONLY:(O_RDWR|O_CREAT),
+  smb_shm_fd = sys_open(file_name, read_only?O_RDONLY:(O_RDWR|O_CREAT),
                     SHM_FILE_MODE);
 
   if ( smb_shm_fd < 0 )
@@ -917,9 +917,9 @@ size (%.0f), using filesize\n", (double)filesize, (double)size));
     size = filesize;
   }
    
-  smb_shm_header_p = (struct SmbShmHeader *)mmap(NULL, size, 
+  smb_shm_header_p = (struct SmbShmHeader *)sys_mmap(NULL, size, 
                                read_only?PROT_READ: (PROT_READ | PROT_WRITE), 
-                               MAP_FILE | MAP_SHARED, smb_shm_fd, 0);
+                               MAP_FILE | MAP_SHARED, smb_shm_fd, (SMB_OFF_T)0);
 
   /* 
    * WARNING, smb_shm_header_p can be different for different
index 1493c87f8a22385c255c50f56ed619b66842a401..8d6d139867d22295a47a2592a2ef58e16eb0301a 100644 (file)
@@ -611,7 +611,7 @@ void dump_all_namelists(void)
   pstrcat(fname,"/"); 
   pstrcat(fname,"namelist.debug");
 
-  fp = fopen(fname,"w");
+  fp = sys_fopen(fname,"w");
      
   if (!fp)
   { 
index cf7295ee11def48b1fec7e01c1447feb2a69a417..d30e8da64ce3705a5b22636e52d19d738f70cc96 100644 (file)
@@ -345,7 +345,7 @@ void write_browse_list(time_t t, BOOL force_write)
   pstrcpy(fnamenew,fname);
   pstrcat(fnamenew,".");
  
-  fp = fopen(fnamenew,"w");
+  fp = sys_fopen(fnamenew,"w");
  
   if (!fp)
   {
index 8dee5ca4f2a427abd30b2bfc357d5f46ae4148a1..dae25b6eca3b376b1f1b64b40d80c8164a2db805 100644 (file)
@@ -161,7 +161,7 @@ void sync_browse_lists(struct work_record *work,
        DEBUG(2,("Initiating browse sync for %s to %s(%s)\n",
                 work->work_group, name, inet_ntoa(ip)));
 
-       fp = fopen(s->fname,"w");
+       fp = sys_fopen(s->fname,"w");
        if (!fp) _exit(1);      
 
        sync_child(name, nm_type, work->work_group, ip, local, servers,
@@ -239,7 +239,7 @@ static void complete_sync(struct sync_record *s)
        char *ptr;
        int count=0;
 
-       f = fopen(s->fname,"r");
+       f = sys_fopen(s->fname,"r");
 
        if (!f) return;
        
index 0906715af4081ade7e28234a8636c1b1916da116..35ca5af62c4774ee5e3e9e360f1e769422e3b259 100644 (file)
@@ -157,7 +157,7 @@ BOOL initialise_wins(void)
   pstrcat(fname,"/");
   pstrcat(fname,WINS_LIST);
 
-  if((fp = fopen(fname,"r")) == NULL)
+  if((fp = sys_fopen(fname,"r")) == NULL)
   {
     DEBUG(2,("initialise_wins: Can't open wins database file %s. Error was %s\n",
            fname, strerror(errno) ));
@@ -1555,7 +1555,7 @@ void wins_write_database(BOOL background)
   string_sub(fname,"//", "/");
   slprintf(fnamenew,sizeof(fnamenew),"%s.%u", fname, (unsigned int)getpid());
 
-  if((fp = fopen(fnamenew,"w")) == NULL)
+  if((fp = sys_fopen(fnamenew,"w")) == NULL)
   {
     DEBUG(0,("wins_write_database: Can't open %s. Error was %s\n", fnamenew, strerror(errno)));
     if (background) {
index 2f54b7213173cca92700c4be42589e5997c220ed..74dd3d7a254830afb58035cac9d8972be48052c4 100644 (file)
@@ -499,7 +499,7 @@ static FILE *OpenConfFile( char *FileName )
     return( NULL );
     }
 
-  OpenedFile = fopen( FileName, "r" );
+  OpenedFile = sys_fopen( FileName, "r" );
   if( NULL == OpenedFile )
     {
     DEBUG( lvl,
index a4c663e388264395c33e7f24a6658d0d380dc330..da45f15f5fae97456c961ec20e9eeb3e62967f82 100644 (file)
@@ -548,7 +548,7 @@ char *pwdb_encode_acct_ctrl(uint16 acct_ctrl, size_t length)
  15 lines, which is more important.
  **********************************************************/
 
-uint16 pwdb_decode_acct_ctrl(char *p)
+uint16 pwdb_decode_acct_ctrl(const char *p)
 {
        uint16 acct_ctrl = 0;
        BOOL finished = False;
@@ -591,7 +591,7 @@ uint16 pwdb_decode_acct_ctrl(char *p)
  gets password-database-format time from a string.
  ********************************************************************/
 
-static time_t get_time_from_string(char *p)
+static time_t get_time_from_string(const char *p)
 {
        int i;
 
@@ -609,7 +609,7 @@ static time_t get_time_from_string(char *p)
                 * read into a time_t as the seconds since
                 * 1970 that the password was last changed.
                 */
-               return (time_t)strtol((char *)p, NULL, 16);
+               return (time_t)strtol(p, NULL, 16);
        }
        return (time_t)-1;
 }
@@ -618,9 +618,9 @@ static time_t get_time_from_string(char *p)
  gets password last set time
  ********************************************************************/
 
-time_t pwdb_get_last_set_time(char *p)
+time_t pwdb_get_last_set_time(const char *p)
 {
-       if (*p && StrnCaseCmp((char *)p, "LCT-", 4))
+       if (*p && StrnCaseCmp(p, "LCT-", 4))
        {
                return get_time_from_string(p + 4);
        }
index bdf01ee6a8bfc01c37d7314a20f6b335c6c3f287..67f8ea6cfb670c12b73060dc4579c05456737bde 100644 (file)
@@ -118,14 +118,14 @@ static struct smb_passwd *getsmbfilepwent(void *vp)
                 * As 256 is shorter than a pstring we don't need to check
                 * length here - if this ever changes....
                 */
-               p = strncpyn(user_name, linebuf, sizeof(user_name), ':');
+               p = (unsigned char *)strncpyn(user_name, linebuf, sizeof(user_name), ':');
 
                /* Go past ':' */
                p++;
 
                /* Get smb uid. */
 
-               p = Atoic((char *) p, &uidval, ":");
+               p = (unsigned char *)Atoic((char *) p, &uidval, ":");
 
                pw_buf.smb_name = user_name;
                pw_buf.smb_userid = uidval;
@@ -218,7 +218,7 @@ static struct smb_passwd *getsmbfilepwent(void *vp)
                        if (*p == ':')
                        {
                                p++;
-                               pw_buf.pass_last_set_time = pwdb_get_last_set_time(p);
+                               pw_buf.pass_last_set_time = pwdb_get_last_set_time((char *)p);
                        }
                }
                else
@@ -522,7 +522,7 @@ static BOOL mod_smbfilepwd_entry(struct smb_passwd* pwd, BOOL override)
   }
   DEBUG(10, ("mod_smbfilepwd_entry: opening file %s\n", pfile));
 
-  fp = fopen(pfile, "r+");
+  fp = sys_fopen(pfile, "r+");
 
   if (fp == NULL) {
     DEBUG(0, ("mod_smbfilepwd_entry: unable to open file %s\n", pfile));
index 71bfc65f84b3b4f2d87fe3d553c9bda5c6e8f127..1a3c100fa56e38d96f133e51747a670f2d9b309f 100644 (file)
@@ -93,7 +93,7 @@ account without a valid system user.\n", user_name);
                FILE *fp;
                slprintf(msg_str,msg_str_len-1,
                        "smbpasswd file did not exist - attempting to create it.\n");
-               fp = fopen(lp_smb_passwd_file(), "w");
+               fp = sys_fopen(lp_smb_passwd_file(), "w");
                if (fp) {
                        fprintf(fp, "# Samba SMB password file\n");
                        fclose(fp);
index a50bc93eacce0e24ef2827ec3d249c8a835b0082..51eb799fc2c11763cdd5b0048ef7afa33ea9f495 100644 (file)
@@ -66,9 +66,9 @@ BOOL trust_password_lock( char *domain, char *name, BOOL update)
 
     get_trust_account_file_name( domain, name, mac_file);
 
-    if((mach_passwd_fp = fopen(mac_file, "r+b")) == NULL) {
+    if((mach_passwd_fp = sys_fopen(mac_file, "r+b")) == NULL) {
       if(errno == ENOENT && update) {
-        mach_passwd_fp = fopen(mac_file, "w+b");
+        mach_passwd_fp = sys_fopen(mac_file, "w+b");
       }
 
       if(mach_passwd_fp == NULL) {
index 9454becc999cba4f853cb3d06caf4c71a05c628e..f3a0d4244b9e4dfe69b0def43978752c15de5eff 100644 (file)
@@ -77,9 +77,8 @@ static struct smb_passwd *getsmbfilegrpent(void *vp,
        static pstring  user_name;
        struct passwd *pwfile;
        pstring         linebuf;
-       unsigned char  *p;
+       char  *p;
        int            uidval;
-       size_t            linebuf_len;
 
        if (vp == NULL)
        {
@@ -92,7 +91,7 @@ static struct smb_passwd *getsmbfilegrpent(void *vp,
        /*
         * Scan the file, a line at a time.
         */
-       while ((linebuf_len = getfileline(vp, linebuf, sizeof(linebuf))) > 0)
+       while (getfileline(vp, linebuf, sizeof(linebuf)) > 0)
        {
                /*
                 * The line we have should be of the form :-
index d51e69ad7433d729275f153dd607e06aeb2ca6e8..242406c9748ec863e5f34776a6ebfe6a4a527eca 100644 (file)
@@ -101,7 +101,7 @@ static void ScanQconfig_fn(char *psz,void (*fn)())
        *name = 0;
        *comment = 0;
 
-       if ((pfile = fopen(psz, "r")) == NULL)
+       if ((pfile = sys_fopen(psz, "r")) == NULL)
        {
              DEBUG(0,( "Unable to open qconfig file %s for read!\n", psz));
              return;
@@ -176,7 +176,7 @@ static BOOL ScanQconfig(char *psz,char *pszPrintername)
                DEBUG(0,(" Unable to allocate memory for printer %s\n",pszPrintername));
                return(False);
        }
-       if ((pfile = fopen(psz, "r")) == NULL)
+       if ((pfile = sys_fopen(psz, "r")) == NULL)
        {
              DEBUG(0,( "Unable to open qconfig file %s for read!\n", psz));
              free(pName);
@@ -272,7 +272,7 @@ BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname)
      return(ScanQconfig(psz,pszPrintername));
 #endif
 
-  if ((pfile = fopen(psz, "r")) == NULL)
+  if ((pfile = sys_fopen(psz, "r")) == NULL)
     {
       DEBUG(0,( "Unable to open printcap file %s for read!\n", psz));
       return(False);
@@ -344,7 +344,7 @@ void pcap_printer_fn(void (*fn)(char *, char *))
   }
 #endif
 
-  if ((pfile = fopen(psz, "r")) == NULL)
+  if ((pfile = sys_fopen(psz, "r")) == NULL)
     {
       DEBUG(0,( "Unable to open printcap file %s for read!\n", psz));
       return;
index d779a42ec79dbf3ca4be15308f34486187cdcb6c..dfb87dc6fadcf280c73d2ce7b0c93bd9139e547d 100644 (file)
@@ -1009,7 +1009,7 @@ int get_printqueue(int snum,
 
        lpq_cache_reset[snum] = False;
 
-       f = fopen(outfile,"r");
+       f = sys_fopen(outfile,"r");
        if (!f) {
                return(0);
        }
index 68c51a860ab616c1d28062cea78bec13fa7cdba3..7b970d27d240327f74672673c222197a694b78a8 100644 (file)
@@ -807,12 +807,11 @@ static void samr_reply_lookup_ids(SAMR_Q_LOOKUP_IDS *q_u,
                else if (sid_equal(&dom_sid, &usr_sid))
                {
                        DOMAIN_GRP *mem_grp = NULL;
-                       BOOL ret;
 
                        DEBUG(5,("lookup on Domain SID\n"));
 
                        become_root(True);
-                       ret = getusergroupsnam(sam_pass->smb_name, &mem_grp, &num_rids);
+                       getusergroupsnam(sam_pass->smb_name, &mem_grp, &num_rids);
                        unbecome_root(True);
 
                        num_rids = MIN(num_rids, MAX_SAM_ENTRIES);
@@ -1370,10 +1369,9 @@ static void samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u,
        if (status == 0x0)
        {
                DOMAIN_GRP *mem_grp = NULL;
-               BOOL ret;
 
                become_root(True);
-               ret = getusergroupsnam(sam_pass->smb_name, &mem_grp, &num_groups);
+               getusergroupsnam(sam_pass->smb_name, &mem_grp, &num_groups);
                unbecome_root(True);
 
                 gids = NULL;
index 29cc1c936c4f7b6374f7297f8a1f8a06cdd2d960..6428e965f70ceff623b6a60c14a571cbdf60d567 100644 (file)
@@ -69,7 +69,7 @@ DOM_SID global_sid_S_1_3_1;    /* Creator group */
 DOM_SID global_sid_S_1_3_2;    /* Creator owner server */
 DOM_SID global_sid_S_1_3_3;    /* Creator group server */
 
-extern pstring global_myworkgroup;
+extern fstring global_myworkgroup;
 /* extern fstring global_member_dom_name; */
 
 static struct sid_name_map_info
@@ -254,7 +254,7 @@ BOOL generate_sam_sid(void)
 
        pstrcat(sid_file, "MACHINE.SID");
     
-       if ((fd = open(sid_file, O_RDWR | O_CREAT, 0644)) == -1) {
+       if ((fd = sys_open(sid_file, O_RDWR | O_CREAT, 0644)) == -1) {
                DEBUG(0,("unable to open or create file %s. Error was %s\n",
                         sid_file, strerror(errno) ));
                return False;
index b3422e5b3d1a9b2977364b93f684cf6da7894549..4eda8fd537fd1374e71d9b2f03e3e2c6b1b05306 100755 (executable)
@@ -29,7 +29,7 @@ for sect in 1 5 7 8 ; do
  
        if (rm -f $FNAME && touch $FNAME); then
          rm $FNAME
-         if [ x$GROFF = x ] ; then
+         if [ "x$GROFF" = x ] ; then
            cp $s $m              # Copy raw nroff 
          else
            echo "\t$FNAME"       # groff'ing can be slow, give the user
index 52ca364070a04d68758f624b553c5d2b7fde6759..69ac69b59b174a1bd736f99cb2f82f2a27525fc8 100644 (file)
@@ -65,7 +65,7 @@ static int findpty(char **slave)
 #endif /* !HAVE_GRANTPT */
   
 #if defined(HAVE_GRANTPT)
-  if ((master = open("/dev/ptmx", O_RDWR)) >= 1) {
+  if ((master = sys_open("/dev/ptmx", O_RDWR, 0)) >= 1) {
     grantpt(master);
     unlockpt(master);
     *slave = ptsname(master);
@@ -90,7 +90,7 @@ static int findpty(char **slave)
       DEBUG(3,("pty: try to open %s, line was %s\n", dpname, line ) );
       line[8] = dpname[3];
       line[9] = dpname[4];
-      if ((master = open(line, O_RDWR)) >= 0) {
+      if ((master = sys_open(line, O_RDWR, 0)) >= 0) {
         DEBUG(3,("pty: opened %s\n", line ) );
         line[5] = 't';
         *slave = line;
@@ -133,7 +133,7 @@ static int dochild(int master,char *slavedev, char *name, char *passwordprogram,
   }
 
   /* Open slave pty and acquire as new controlling terminal. */
-  if ((slave = open(slavedev, O_RDWR)) < 0) {
+  if ((slave = sys_open(slavedev, O_RDWR, 0)) < 0) {
     DEBUG(3,("More weirdness, could not open %s\n", 
             slavedev));
     return(False);
index af74e40f6a5608ed69a5a6a244cdbbef90fe5eff..db6c66f1d51cd32f568f8a9b7dc49c316c938e8f 100644 (file)
@@ -51,7 +51,7 @@ BOOL yield_connection(connection_struct *conn,char *name,int max_connections)
        pstrcat(fname,name);
        pstrcat(fname,".LCK");
 
-       fd = open(fname,O_RDWR);
+       fd = sys_open(fname,O_RDWR,0);
        if (fd == -1) {
                DEBUG(2,("Couldn't open lock file %s (%s)\n",fname,strerror(errno)));
                return(False);
@@ -137,11 +137,11 @@ BOOL claim_connection(connection_struct *conn,char *name,int max_connections,BOO
        pstrcat(fname,".LCK");
        
        if (!file_exist(fname,NULL)) {
-               fd = open(fname,O_RDWR|O_CREAT|O_EXCL, 0644);
+               fd = sys_open(fname,O_RDWR|O_CREAT|O_EXCL, 0644);
        }
 
        if (fd == -1) {
-               fd = open(fname,O_RDWR);
+               fd = sys_open(fname,O_RDWR,0);
        }
        
        if (fd == -1) {
index 2b87cad33094d035ed5d3d051eac8b99eead8db9..44625cf54a7070084db4424e458854e7bcb84f62 100644 (file)
@@ -330,7 +330,7 @@ static void load_name_map(GROUP_TYPE type)
         * Load the file.
         */
 
-       fp = fopen(map_file,"r");
+       fp = sys_fopen(map_file,"r");
        if (!fp)
        {
                DEBUG(0,("load_name_map: can't open name map %s. Error was %s\n",
@@ -461,7 +461,7 @@ static BOOL map_sid_to_ntname(GROUP_TYPE type, ubi_slList *map_list,
                        {
                                fstrcpy(ntname, gmep->grp.nt_domain);
                        }
-                       DEBUG(7,("map_sid_to_ntname: Mapping unix group %s to nt group \%s\%s\n",
+                       DEBUG(7,("map_sid_to_ntname: Mapping unix group %s to nt group \\%s\\%s\n",
                               gmep->grp.unix_name,
                               gmep->grp.nt_domain, gmep->grp.nt_name ));
                        return True;
index eed5a71401750d638129fe10b9f865807956617a..d5ff7ddf28e36a71e96aa086909e03985900696e 100644 (file)
@@ -635,7 +635,7 @@ static void fill_printq_info(connection_struct *conn, int snum, int uLevel,
     pstring fname;
 
     pstrcpy(fname,lp_driverfile());
-    f=fopen(fname,"r");
+    f=sys_fopen(fname,"r");
     if (!f) {
       DEBUG(3,("fill_printq_info: Can't open %s - %s\n",fname,strerror(errno)));
       desc->errcode=NERR_notsupported;
@@ -741,7 +741,7 @@ static int get_printerdrivernumber(int snum)
   pstrcpy(fname,lp_driverfile());
 
   DEBUG(4,("In get_printerdrivernumber: %s\n",fname));
-  f=fopen(fname,"r");
+  f=sys_fopen(fname,"r");
   if (!f) {
     DEBUG(3,("get_printerdrivernumber: Can't open %s - %s\n",fname,strerror(errno)));
     return(0);
@@ -999,7 +999,7 @@ static int get_server_info(uint32 servertype,
   pstrcat(fname,"/");
   pstrcat(fname,SERVER_LIST);
 
-  f = fopen(fname,"r");
+  f = sys_fopen(fname,"r");
 
   if (!f) {
     DEBUG(4,("Can't open %s - %s\n",fname,strerror(errno)));
index 001fc652b291b83d0616cf143c737c38eb99fed1..d13dfda1e02c623f9e49ae30518f7c678a816089 100644 (file)
@@ -56,7 +56,7 @@ static void msg_deliver(void)
   slprintf(s,sizeof(s)-1, "%s/msg.XXXXXX",tmpdir());
   fstrcpy(name,(char *)mktemp(s));
 
-  fd = open(name,O_WRONLY|O_CREAT|O_TRUNC|O_EXCL,0600);
+  fd = sys_open(name,O_WRONLY|O_CREAT|O_TRUNC|O_EXCL,0600);
   if (fd == -1) {
     DEBUG(1,("can't open message file %s\n",name));
     return;
index c81334c8ae56ba889d6208435316cf16f1801033..d7cef6d63b99358287d6ab0f577910f643482140 100644 (file)
@@ -552,8 +552,8 @@ static void mmap_open_file(files_struct *fsp)
   if (!fsp->can_write) {
          fsp->mmap_size = file_size(fsp->fsp_name);
          if (fsp->mmap_size < MAX_MMAP_SIZE) {
-                 fsp->mmap_ptr = (char *)mmap(NULL,fsp->mmap_size,
-                                              PROT_READ,MAP_SHARED,fsp->fd_ptr->fd,0);
+                 fsp->mmap_ptr = (char *)sys_mmap(NULL,fsp->mmap_size,
+                                              PROT_READ,MAP_SHARED,fsp->fd_ptr->fd,(SMB_OFF_T)0);
 
                  if (fsp->mmap_ptr == (char *)-1 || !fsp->mmap_ptr) {
                          DEBUG(3,("Failed to mmap() %s - %s\n",
index 19a3afa9981e8264eac1698b6bffa01b23bc6714..1d38b362ec042308defd14a2fc933f41f8fe8aa7 100644 (file)
@@ -1056,7 +1056,7 @@ void check_kernel_oplocks(void)
       return;
     }
 
-    if((fd = open(tmpname, O_RDWR|O_CREAT|O_TRUNC|O_EXCL, 0600)) < 0) {
+    if((fd = sys_open(tmpname, O_RDWR|O_CREAT|O_TRUNC|O_EXCL, 0600)) < 0) {
       DEBUG(0,("check_kernel_oplocks: Unable to open temp test file %s. Error was %s\n",
             tmpname, strerror(errno) ));
       unlink( tmpname );
index 0c8eb124ff5d6b854b5f92494c82f10c5db11042..9011b9b95e1e3f02cad07578c5836c719d9d9e8c 100644 (file)
@@ -813,7 +813,7 @@ static BOOL check_user_equiv(char *user, char *remote, char *equiv_file)
   int plus_allowed = 1;
   char *file_host;
   char *file_user;
-  FILE *fp = fopen(equiv_file, "r");
+  FILE *fp = sys_fopen(equiv_file, "r");
   DEBUG(5, ("check_user_equiv %s %s %s\n", user, remote, equiv_file));
   if (! fp) return False;
   while(fgets(buf, sizeof(buf), fp)) 
index 5cd5a895c6b06bbe5d005cd7d4a81ece2bff7dbd..afabb1befdf3d6ccb70c4079ea4bbe22a9ace762 100644 (file)
@@ -270,7 +270,7 @@ BOOL disk_quotas(char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB_BIG_U
   if ( devno != devno_cached ) {
     devno_cached = devno ;
 #if defined(SUNOS5)
-    if ((fd = fopen(MNTTAB, "r")) == NULL)
+    if ((fd = sys_fopen(MNTTAB, "r")) == NULL)
       return(False) ;
     
     found = False ;
@@ -320,7 +320,7 @@ BOOL disk_quotas(char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB_BIG_U
 
 #if defined(SUNOS5)
   DEBUG(5,("disk_quotas: looking for quotas file \"%s\"\n", name));
-  if((file=open(name, O_RDONLY))<0) {
+  if((file=sys_open(name, O_RDONLY,0))<0) {
     setuid(user_id);  /* Restore the original UID status */
     seteuid(euser_id);
     return(False);
index 2ee019b2dcb356a18decdb5476fc3fd98018e63b..f679e4a8a8cd1277c7de4a7c1cb4771d17829804 100644 (file)
@@ -40,7 +40,7 @@ void smbw_setup_shared(void)
        fstrcpy(name,(char *)mktemp(s));
 
        /* note zero permissions! don't change this */
-       fd = open(name,O_RDWR|O_CREAT|O_TRUNC|O_EXCL,0); 
+       fd = sys_open(name,O_RDWR|O_CREAT|O_TRUNC|O_EXCL,0); 
        if (fd == -1) goto failed;
        unlink(name);
 
index 7c857652344dec4dba98e23e75cfba5da27ebba4..faaa9f047b0537b9aa552f97d010361215a4c1ba 100644 (file)
@@ -65,7 +65,7 @@ void smbw_init(void)
        dbf = stderr;
 
        if ((p=smbw_getshared("LOGFILE"))) {
-               dbf = fopen(p, "a");
+               dbf = sys_fopen(p, "a");
        }
 
        smbw_file_bmap = bitmap_allocate(SMBW_MAX_OPEN);
index c64ce64bbf566dcc3f3aed8eeac725be1b034cc4..68b603bf1f6a2f66930ab20a1f693810277954f0 100644 (file)
@@ -471,7 +471,7 @@ int main(int argc, char *argv[])
     return(-1);
   }
 
-  inf_file=fopen(argv[1],"r");  
+  inf_file=sys_fopen(argv[1],"r");  
   if (!inf_file)
   {
     fprintf(stderr,"Description file not found, bye\n");
index 0653fd31f1a89487753b1619c6b2e16b62bb0a46..a57af2fc4404faeb22691e0870dd7b21f8250f61 100644 (file)
@@ -190,7 +190,7 @@ The maximum size I will believe is 100k.\n", prog_name, size);
     exit(1);
   }
 
-  if((fp = fopen(input_file, "r")) == NULL)
+  if((fp = sys_fopen(input_file, "r")) == NULL)
   {
     fprintf(stderr, "%s: cannot open file %s for input.\n", prog_name, input_file);
     exit(1);
@@ -283,7 +283,7 @@ definition file. File %s has %d.\n", prog_name, MAXCODEPAGELINES, input_file, nu
   }
 
   /* Now write out the output_buf. */
-  if((fp = fopen(output_file, "w"))==NULL)
+  if((fp = sys_fopen(output_file, "w"))==NULL)
   {
     fprintf(stderr, "%s: Cannot open output file %s. Error was %s.\n",
             prog_name, output_file, strerror(errno));
@@ -339,7 +339,7 @@ code page file.\n", prog_name, input_file);
      is held in little endian format.
    */
     
-  if((fp = fopen( input_file, "r")) == NULL)
+  if((fp = sys_fopen( input_file, "r")) == NULL)
   { 
     fprintf(stderr, "%s: cannot open file %s. Error was %s\n",
               prog_name, input_file, strerror(errno));
@@ -411,7 +411,7 @@ multiple of 4.\n", prog_name, input_file);
   fclose(fp);
     
   /* Now dump the codepage into an ascii file. */
-  if((fp = fopen(output_file, "w")) == NULL)
+  if((fp = sys_fopen(output_file, "w")) == NULL)
   {
     fprintf(stderr, "%s: cannot open file %s. Error was %s\n",
               prog_name, output_file, strerror(errno));
index fa1e8b43bfd806ef7cce80a351a6a86a3dd1cb27..96df0878581aca89a7f9b4c5510f70a9b8c09eba 100644 (file)
@@ -211,7 +211,7 @@ static void print_share_mode(share_mode_entry *e, char *fname)
   trim_string(fname,"","/");
   pstrcat(fname,"/STATUS..LCK");
 
-  f = fopen(fname,"r");
+  f = sys_fopen(fname,"r");
   if (!f) {
     printf("Couldn't open status file %s\n",fname);
     if (!lp_status(-1))
index caa9e2740a070e7fb553e29b04f3d0c0c8e58a9e..c03fa0436a6466603c7f08dde2cd5cf9b3bb365a 100644 (file)
@@ -52,7 +52,7 @@ int main(int argc, char *argv[])
       printf("Usage: testprns printername [printcapfile]\n");
    else
    {
-      dbf = fopen("test.log", "w");
+      dbf = sys_fopen("test.log", "w");
       if (dbf == NULL) {
          printf("Unable to open logfile.\n");
       } else {
index db2cfb4555a52a2e1c934afa2b1b3d37e8e627bb..009244e5957a647b239a132b7321289fa69d1a90 100644 (file)
@@ -437,7 +437,7 @@ static void cgi_download(char *file)
                cgi_setup_error("404 File Not Found","",
                                "The requested file was not found");
        }
-       fd = open(file,O_RDONLY);
+       fd = sys_open(file,O_RDONLY,0);
        if (fd == -1) {
                cgi_setup_error("404 File Not Found","",
                                "The requested file was not found");
@@ -493,7 +493,7 @@ void cgi_setup(char *rootdir, int auth_required)
        inetd_server = True;
 
 #if CGI_LOGGING
-       f = fopen("/tmp/cgi.log", "a");
+       f = sys_fopen("/tmp/cgi.log", "a");
        if (f) fprintf(f,"\n[Date: %s   %s (%s)]\n", 
                       http_timestring(time(NULL)),
                       client_name(1), client_addr(1));
index 184f7e1f73c1d0ba158b78f89ad18718cc0d9ead..81564390a0c1c41051c261a75c1f84f907b7e869 100644 (file)
@@ -124,7 +124,7 @@ void status_page(void)
        pstrcat(fname,"/STATUS..LCK");
 
 
-       f = fopen(fname,"r");
+       f = sys_fopen(fname,"r");
        if (f) {
                while (!feof(f)) {
                        if (fread(&crec,sizeof(crec),1,f) != 1) break;
@@ -157,7 +157,7 @@ void status_page(void)
 
        printf("<p>\n");
 
-       f = fopen(fname,"r");
+       f = sys_fopen(fname,"r");
        if (!f) {
                printf("Couldn't open status file %s\n",fname);
                if (!lp_status(-1))
index cdbd1f8c8c47c6287d79997125610f53e6d2dd45..7004891f32f2bea0aea586c61039dd4b24bb05ff 100644 (file)
@@ -106,7 +106,7 @@ static char *make_parm_name(char *label)
 ****************************************************************************/
 static int include_html(char *fname)
 {
-       FILE *f = fopen(fname,"r");
+       FILE *f = sys_fopen(fname,"r");
        char buf[1024];
        int ret;
 
@@ -318,7 +318,7 @@ static int save_reload(void)
 {
        FILE *f;
 
-       f = fopen(servicesf,"w");
+       f = sys_fopen(servicesf,"w");
        if (!f) {
                printf("failed to open %s for writing\n", servicesf);
                return 0;
@@ -894,7 +894,7 @@ static void printers_page(void)
        /* just in case it goes wild ... */
        alarm(300);
 
-       dbf = fopen("/dev/null", "w");
+       dbf = sys_fopen("/dev/null", "w");
 
        if (!dbf) dbf = stderr;