diff options
author | Jeremy Allison <jra@samba.org> | 1998-11-17 20:50:07 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 1998-11-17 20:50:07 +0000 |
commit | 768761820e8d7481c586c4e0ab4ac7cb36d18c4b (patch) | |
tree | 675f36b6854bfccca433842e68e0df4b86cda575 /source3 | |
parent | bb5bea4e195eaf5776284c027d667812b7365b56 (diff) | |
download | samba-768761820e8d7481c586c4e0ab4ac7cb36d18c4b.tar.gz samba-768761820e8d7481c586c4e0ab4ac7cb36d18c4b.tar.bz2 samba-768761820e8d7481c586c4e0ab4ac7cb36d18c4b.zip |
Added the same open()/fopen()/creat()/mmap() -> sys_XXX calls.
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)
Diffstat (limited to 'source3')
56 files changed, 238 insertions, 178 deletions
diff --git a/source3/client/client.c b/source3/client/client.c index 8356d99b7b..c4c269293b 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -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", diff --git a/source3/client/clitar.c b/source3/client/clitar.c index e7915d1066..a2b23817f5 100644 --- a/source3/client/clitar.c +++ b/source3/client/clitar.c @@ -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))); diff --git a/source3/configure b/source3/configure index 0ec5ebb0b3..1d5779bf34 100755 --- a/source3/configure +++ b/source3/configure @@ -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 diff --git a/source3/configure.in b/source3/configure.in index 55fe56fe9e..f555087ddf 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -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) diff --git a/source3/groupdb/aliasdb.c b/source3/groupdb/aliasdb.c index e5e6ebfa53..03e0a6e11a 100644 --- a/source3/groupdb/aliasdb.c +++ b/source3/groupdb/aliasdb.c @@ -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; } diff --git a/source3/groupdb/aliasfile.c b/source3/groupdb/aliasfile.c index fc87b47c47..01166bcc1f 100644 --- a/source3/groupdb/aliasfile.c +++ b/source3/groupdb/aliasfile.c @@ -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 */ diff --git a/source3/groupdb/groupfile.c b/source3/groupdb/groupfile.c index 8044071391..09939de71e 100644 --- a/source3/groupdb/groupfile.c +++ b/source3/groupdb/groupfile.c @@ -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 */ diff --git a/source3/include/config.h.in b/source3/include/config.h.in index 49379cfe9c..c5c761ede3 100644 --- a/source3/include/config.h.in +++ b/source3/include/config.h.in @@ -390,6 +390,9 @@ /* 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 @@ -465,6 +468,9 @@ /* 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 diff --git a/source3/include/proto.h b/source3/include/proto.h index 329903f787..d68853b5e6 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -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); diff --git a/source3/lib/charset.c b/source3/lib/charset.c index 5bf3bfbe30..fc2924a155 100644 --- a/source3/lib/charset.c +++ b/source3/lib/charset.c @@ -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))); diff --git a/source3/lib/debug.c b/source3/lib/debug.c index 619a917747..3a90da2f3d 100644 --- a/source3/lib/debug.c +++ b/source3/lib/debug.c @@ -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 ) { diff --git a/source3/lib/genrand.c b/source3/lib/genrand.c index bb1922e4f5..8b05b02f94 100644 --- a/source3/lib/genrand.c +++ b/source3/lib/genrand.c @@ -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 ! diff --git a/source3/lib/kanji.c b/source3/lib/kanji.c index 565e8d852f..871a4a059c 100644 --- a/source3/lib/kanji.c +++ b/source3/lib/kanji.c @@ -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; } diff --git a/source3/lib/pidfile.c b/source3/lib/pidfile.c index 7e98438dba..52a3be875f 100644 --- a/source3/lib/pidfile.c +++ b/source3/lib/pidfile.c @@ -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))); diff --git a/source3/lib/smbrun.c b/source3/lib/smbrun.c index 86d7cf9e03..da7632a67a 100644 --- a/source3/lib/smbrun.c +++ b/source3/lib/smbrun.c @@ -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; diff --git a/source3/lib/system.c b/source3/lib/system.c index deca7e1b6a..d07df3faf0 100644 --- a/source3/lib/system.c +++ b/source3/lib/system.c @@ -231,6 +231,62 @@ SMB_OFF_T sys_ftell(FILE *fp) } /******************************************************************* + 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. ********************************************************************/ int dos_unlink(char *fname) @@ -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; diff --git a/source3/lib/username.c b/source3/lib/username.c index f56f7efce2..f04314ab36 100644 --- a/source3/lib/username.c +++ b/source3/lib/username.c @@ -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; diff --git a/source3/lib/util.c b/source3/lib/util.c index df3faa569a..7247e95c64 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -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); diff --git a/source3/lib/util_file.c b/source3/lib/util_file.c index 0d6e77b010..faceed1dbd 100644 --- a/source3/lib/util_file.c +++ b/source3/lib/util_file.c @@ -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)); diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index 02fa892d7b..c943a854cf 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -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); diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index 1398f7bc49..149b977746 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -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))); diff --git a/source3/locking/locking_slow.c b/source3/locking/locking_slow.c index f1e0fa2149..7c27355224 100644 --- a/source3/locking/locking_slow.c +++ b/source3/locking/locking_slow.c @@ -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; } diff --git a/source3/locking/shmem.c b/source3/locking/shmem.c index 2a4e4de129..435c0d4c78 100644 --- a/source3/locking/shmem.c +++ b/source3/locking/shmem.c @@ -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 diff --git a/source3/nmbd/nmbd_namelistdb.c b/source3/nmbd/nmbd_namelistdb.c index 1493c87f8a..8d6d139867 100644 --- a/source3/nmbd/nmbd_namelistdb.c +++ b/source3/nmbd/nmbd_namelistdb.c @@ -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) { diff --git a/source3/nmbd/nmbd_serverlistdb.c b/source3/nmbd/nmbd_serverlistdb.c index cf7295ee11..d30e8da64c 100644 --- a/source3/nmbd/nmbd_serverlistdb.c +++ b/source3/nmbd/nmbd_serverlistdb.c @@ -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) { diff --git a/source3/nmbd/nmbd_synclists.c b/source3/nmbd/nmbd_synclists.c index 8dee5ca4f2..dae25b6eca 100644 --- a/source3/nmbd/nmbd_synclists.c +++ b/source3/nmbd/nmbd_synclists.c @@ -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; diff --git a/source3/nmbd/nmbd_winsserver.c b/source3/nmbd/nmbd_winsserver.c index 0906715af4..35ca5af62c 100644 --- a/source3/nmbd/nmbd_winsserver.c +++ b/source3/nmbd/nmbd_winsserver.c @@ -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) { diff --git a/source3/param/params.c b/source3/param/params.c index 2f54b72131..74dd3d7a25 100644 --- a/source3/param/params.c +++ b/source3/param/params.c @@ -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, diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c index a4c663e388..da45f15f5f 100644 --- a/source3/passdb/passdb.c +++ b/source3/passdb/passdb.c @@ -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); } diff --git a/source3/passdb/smbpass.c b/source3/passdb/smbpass.c index bdf01ee6a8..67f8ea6cfb 100644 --- a/source3/passdb/smbpass.c +++ b/source3/passdb/smbpass.c @@ -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)); diff --git a/source3/passdb/smbpasschange.c b/source3/passdb/smbpasschange.c index 71bfc65f84..1a3c100fa5 100644 --- a/source3/passdb/smbpasschange.c +++ b/source3/passdb/smbpasschange.c @@ -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); diff --git a/source3/passdb/smbpassfile.c b/source3/passdb/smbpassfile.c index a50bc93eac..51eb799fc2 100644 --- a/source3/passdb/smbpassfile.c +++ b/source3/passdb/smbpassfile.c @@ -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) { diff --git a/source3/passdb/smbpassgroup.c b/source3/passdb/smbpassgroup.c index 9454becc99..f3a0d4244b 100644 --- a/source3/passdb/smbpassgroup.c +++ b/source3/passdb/smbpassgroup.c @@ -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 :- diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c index d51e69ad74..242406c974 100644 --- a/source3/printing/pcap.c +++ b/source3/printing/pcap.c @@ -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; diff --git a/source3/printing/printing.c b/source3/printing/printing.c index d779a42ec7..dfb87dc6fa 100644 --- a/source3/printing/printing.c +++ b/source3/printing/printing.c @@ -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); } diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 68c51a860a..7b970d27d2 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -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; diff --git a/source3/rpc_server/srv_sid.c b/source3/rpc_server/srv_sid.c index 29cc1c936c..6428e965f7 100644 --- a/source3/rpc_server/srv_sid.c +++ b/source3/rpc_server/srv_sid.c @@ -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; diff --git a/source3/script/installman.sh b/source3/script/installman.sh index b3422e5b3d..4eda8fd537 100755 --- a/source3/script/installman.sh +++ b/source3/script/installman.sh @@ -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 diff --git a/source3/smbd/chgpasswd.c b/source3/smbd/chgpasswd.c index 52ca364070..69ac69b59b 100644 --- a/source3/smbd/chgpasswd.c +++ b/source3/smbd/chgpasswd.c @@ -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); diff --git a/source3/smbd/connection.c b/source3/smbd/connection.c index af74e40f6a..db6c66f1d5 100644 --- a/source3/smbd/connection.c +++ b/source3/smbd/connection.c @@ -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) { diff --git a/source3/smbd/groupname.c b/source3/smbd/groupname.c index 2b87cad330..44625cf54a 100644 --- a/source3/smbd/groupname.c +++ b/source3/smbd/groupname.c @@ -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; diff --git a/source3/smbd/ipc.c b/source3/smbd/ipc.c index eed5a71401..d5ff7ddf28 100644 --- a/source3/smbd/ipc.c +++ b/source3/smbd/ipc.c @@ -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))); diff --git a/source3/smbd/message.c b/source3/smbd/message.c index 001fc652b2..d13dfda1e0 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -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; diff --git a/source3/smbd/open.c b/source3/smbd/open.c index c81334c8ae..d7cef6d63b 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -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", diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c index 19a3afa998..1d38b362ec 100644 --- a/source3/smbd/oplock.c +++ b/source3/smbd/oplock.c @@ -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 ); diff --git a/source3/smbd/password.c b/source3/smbd/password.c index 0c8eb124ff..9011b9b95e 100644 --- a/source3/smbd/password.c +++ b/source3/smbd/password.c @@ -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)) diff --git a/source3/smbd/quotas.c b/source3/smbd/quotas.c index 5cd5a895c6..afabb1befd 100644 --- a/source3/smbd/quotas.c +++ b/source3/smbd/quotas.c @@ -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); diff --git a/source3/smbwrapper/shared.c b/source3/smbwrapper/shared.c index 2ee019b2dc..f679e4a8a8 100644 --- a/source3/smbwrapper/shared.c +++ b/source3/smbwrapper/shared.c @@ -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); diff --git a/source3/smbwrapper/smbw.c b/source3/smbwrapper/smbw.c index 7c85765234..faaa9f047b 100644 --- a/source3/smbwrapper/smbw.c +++ b/source3/smbwrapper/smbw.c @@ -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); diff --git a/source3/utils/make_printerdef.c b/source3/utils/make_printerdef.c index c64ce64bbf..68b603bf1f 100644 --- a/source3/utils/make_printerdef.c +++ b/source3/utils/make_printerdef.c @@ -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"); diff --git a/source3/utils/make_smbcodepage.c b/source3/utils/make_smbcodepage.c index 0653fd31f1..a57af2fc44 100644 --- a/source3/utils/make_smbcodepage.c +++ b/source3/utils/make_smbcodepage.c @@ -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)); diff --git a/source3/utils/status.c b/source3/utils/status.c index fa1e8b43bf..96df087858 100644 --- a/source3/utils/status.c +++ b/source3/utils/status.c @@ -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)) diff --git a/source3/utils/testprns.c b/source3/utils/testprns.c index caa9e2740a..c03fa0436a 100644 --- a/source3/utils/testprns.c +++ b/source3/utils/testprns.c @@ -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 { diff --git a/source3/web/cgi.c b/source3/web/cgi.c index db2cfb4555..009244e595 100644 --- a/source3/web/cgi.c +++ b/source3/web/cgi.c @@ -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)); diff --git a/source3/web/statuspage.c b/source3/web/statuspage.c index 184f7e1f73..81564390a0 100644 --- a/source3/web/statuspage.c +++ b/source3/web/statuspage.c @@ -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)) diff --git a/source3/web/swat.c b/source3/web/swat.c index cdbd1f8c8c..7004891f32 100644 --- a/source3/web/swat.c +++ b/source3/web/swat.c @@ -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; |