diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/client/client.c | 44 | ||||
-rw-r--r-- | source3/client/clitar.c | 88 | ||||
-rw-r--r-- | source3/include/kanji.h | 9 | ||||
-rw-r--r-- | source3/include/smb.h | 8 | ||||
-rw-r--r-- | source3/lib/charcnv.c | 38 | ||||
-rw-r--r-- | source3/lib/kanji.c | 5 | ||||
-rw-r--r-- | source3/lib/util.c | 432 | ||||
-rw-r--r-- | source3/locking/locking.c | 2 | ||||
-rw-r--r-- | source3/namepacket.c | 5 | ||||
-rw-r--r-- | source3/param/loadparm.c | 15 | ||||
-rw-r--r-- | source3/smbd/mangle.c | 205 | ||||
-rw-r--r-- | source3/smbd/trans2.c | 8 | ||||
-rw-r--r-- | source3/utils/nmblookup.c | 16 |
13 files changed, 486 insertions, 389 deletions
diff --git a/source3/client/client.c b/source3/client/client.c index 4718db84ac..e9042555e2 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -143,12 +143,8 @@ extern int Client; #define USENMB -#ifdef KANJI extern int coding_system; -#define CNV_LANG(s) (coding_system == DOSV_CODE?s:dos_to_unix(s, False)) -#define CNV_INPUT(s) (coding_system == DOSV_CODE?s:unix_to_dos(s, True)) -static BOOL -setup_term_code (char *code) +static BOOL setup_term_code (char *code) { int new; new = interpret_coding_system (code, UNKNOWN_CODE); @@ -158,10 +154,8 @@ setup_term_code (char *code) } return False; } -#else #define CNV_LANG(s) dos2unix_format(s,False) #define CNV_INPUT(s) unix2dos_format(s,True) -#endif /**************************************************************************** setup basics in a outgoing packet @@ -4392,10 +4386,6 @@ static void usage(char *pname) DEBUG(0,("Usage: %s service <password> [-p port] [-d debuglevel] [-l log] ", pname)); -#ifdef KANJI - DEBUG(0,("[-t termcode] ")); -#endif /* KANJI */ - DEBUG(0,("\nVersion %s\n",VERSION)); DEBUG(0,("\t-p port listen on the specified port\n")); DEBUG(0,("\t-d debuglevel set the debuglevel\n")); @@ -4411,9 +4401,7 @@ static void usage(char *pname) DEBUG(0,("\t-U username set the network username\n")); DEBUG(0,("\t-W workgroup set the workgroup name\n")); DEBUG(0,("\t-c command string execute semicolon separated commands\n")); -#ifdef KANJI DEBUG(0,("\t-t terminal code terminal i/o code {sjis|euc|jis7|jis8|junet|hex}\n")); -#endif /* KANJI */ DEBUG(0,("\t-T<c|x>IXgbNa command line tar\n")); DEBUG(0,("\t-D directory start from directory\n")); DEBUG(0,("\n")); @@ -4435,6 +4423,13 @@ static void usage(char *pname) BOOL message = False; extern char tar_type; static pstring servicesf = CONFIGFILE; + pstring term_code; + +#ifdef KANJI + strcpy(term_code, KANJI); +#else /* KANJI */ + *term_code = 0; +#endif /* KANJI */ *query_host = 0; *base_directory = 0; @@ -4506,9 +4501,6 @@ static void usage(char *pname) } } -#ifdef KANJI - setup_term_code (KANJI); -#endif while ((opt = getopt(argc, argv,"s:B:O:M:i:Nn:d:Pp:l:hI:EB:U:L:t:m:W:T:D:c:")) != EOF) switch (opt) @@ -4604,13 +4596,7 @@ static void usage(char *pname) strcpy(servicesf, optarg); break; case 't': -#ifdef KANJI - if (!setup_term_code (optarg)) { - DEBUG(0, ("%s: unknown terminal code name\n", optarg)); - usage (pname); - exit (1); - } -#endif + strcpy(term_code, optarg); break; default: usage(pname); @@ -4635,6 +4621,18 @@ static void usage(char *pname) fprintf(stderr, "Can't load %s - run testparm to debug it\n", servicesf); } + codepage_initialise(lp_client_code_page()); + + if(lp_client_code_page() == KANJI_CODEPAGE) + { + if (!setup_term_code (term_code)) + { + DEBUG(0, ("%s: unknown terminal code name\n", optarg)); + usage (pname); + exit (1); + } + } + if (*workgroup == 0) strcpy(workgroup,lp_workgroup()); diff --git a/source3/client/clitar.c b/source3/client/clitar.c index d5bca8c5bb..a30f6c2960 100644 --- a/source3/client/clitar.c +++ b/source3/client/clitar.c @@ -306,27 +306,35 @@ static void fixtarname(char *tptr, char *fp, int l) * to lovely unix /'s :-} */ *tptr++='.'; -#ifdef KANJI - while (l > 0) { - if (is_shift_jis (*fp)) { - *tptr++ = *fp++; - *tptr++ = *fp++; - l -= 2; - } else if (is_kana (*fp)) { - *tptr++ = *fp++; - l--; - } else if (*fp == '\\') { - *tptr++ = '/'; + if(lp_client_code_page() == KANJI_CODEPAGE) + { + while (l > 0) { + if (is_shift_jis (*fp)) { + *tptr++ = *fp++; + *tptr++ = *fp++; + l -= 2; + } else if (is_kana (*fp)) { + *tptr++ = *fp++; + l--; + } else if (*fp == '\\') { + *tptr++ = '/'; + fp++; + l--; + } else { + *tptr++ = *fp++; + l--; + } + } + } + else + { + while (l--) + { + *tptr=(*fp == '\\') ? '/' : *fp; + tptr++; fp++; - l--; - } else { - *tptr++ = *fp++; - l--; } } -#else - while (l--) { *tptr=(*fp == '\\') ? '/' : *fp; tptr++; fp++; } -#endif } /**************************************************************************** @@ -1203,27 +1211,35 @@ static void unfixtarname(char *tptr, char *fp, int l) if (*fp == '.') fp++; if (*fp == '\\' || *fp == '/') fp++; -#ifdef KANJI - while (l > 0) { - if (is_shift_jis (*fp)) { - *tptr++ = *fp++; - *tptr++ = *fp++; - l -= 2; - } else if (is_kana (*fp)) { - *tptr++ = *fp++; - l--; - } else if (*fp == '/') { - *tptr++ = '\\'; + if(lp_client_code_page() == KANJI_CODEPAGE) + { + while (l > 0) { + if (is_shift_jis (*fp)) { + *tptr++ = *fp++; + *tptr++ = *fp++; + l -= 2; + } else if (is_kana (*fp)) { + *tptr++ = *fp++; + l--; + } else if (*fp == '/') { + *tptr++ = '\\'; + fp++; + l--; + } else { + *tptr++ = *fp++; + l--; + } + } + } + else + { + while (l--) + { + *tptr=(*fp == '/') ? '\\' : *fp; + tptr++; fp++; - l--; - } else { - *tptr++ = *fp++; - l--; } } -#else - while (l--) { *tptr=(*fp == '/') ? '\\' : *fp; tptr++; fp++; } -#endif } static void do_tarput() diff --git a/source3/include/kanji.h b/source3/include/kanji.h index 865ac3b2c9..1d2359baa9 100644 --- a/source3/include/kanji.h +++ b/source3/include/kanji.h @@ -27,8 +27,6 @@ #ifndef _KANJI_H_ #define _KANJI_H_ -#ifdef KANJI - /* FOR SHIFT JIS CODE */ #define is_shift_jis(c) \ ((0x81 <= ((unsigned char) (c)) && ((unsigned char) (c)) <= 0x9f) \ @@ -110,9 +108,6 @@ extern char* (*_dos_to_unix) (const char *str, BOOL overwrite); extern char* (*_unix_to_dos) (const char *str, BOOL overwrite); -#define unix_to_dos (*_unix_to_dos) -#define dos_to_unix (*_dos_to_unix) - extern char *sj_strtok (char *s1, const char *s2); extern char *sj_strchr (const char *s, int c); extern char *sj_strrchr (const char *s, int c); @@ -137,11 +132,7 @@ extern char *sj_strstr (const char *s1, const char *s2); int interpret_coding_system (char *str, int def); -#else - #define unix_to_dos(x,y) unix2dos_format(x,y) #define dos_to_unix(x,y) dos2unix_format(x,y) -#endif /* not KANJI */ - #endif /* _KANJI_H_ */ diff --git a/source3/include/smb.h b/source3/include/smb.h index b55c180f36..47fbf32f83 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -926,14 +926,16 @@ enum case_handling {CASE_LOWER,CASE_UPPER}; #endif +/* Defines needed for multi-codepage support. */ +#define KANJI_CODEPAGE 932 + #ifdef KANJI -/* Default client code page - 932 - Japanese */ -#define DEFAULT_CLIENT_CODE_PAGE 932 +/* Default client code page - Japanese */ +#define DEFAULT_CLIENT_CODE_PAGE KANJI_CODEPAGE #else /* KANJI */ /* Default client code page - 850 - Western European */ #define DEFAULT_CLIENT_CODE_PAGE 850 #endif /* KANJI */ - /* Size of buffer to use when moving files across filesystems. */ #define COPYBUF_SIZE (8*1024) diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c index 6be455c47b..a7dff4224b 100644 --- a/source3/lib/charcnv.c +++ b/source3/lib/charcnv.c @@ -107,13 +107,18 @@ char *unix2dos_format(char *str,BOOL overwrite) char *dp; if (!mapsinited) initmaps(); - if (overwrite) { - for (p = str; *p; p++) *p = unix2dos[(unsigned char)*p]; - return str; - } else { - for (p = str, dp = cvtbuf; *p; p++,dp++) *dp = unix2dos[(unsigned char)*p]; - *dp = 0; - return cvtbuf; + + if(lp_client_code_page() == KANJI_CODEPAGE) + return (*_unix_to_dos)(str, overwrite); + else { + if (overwrite) { + for (p = str; *p; p++) *p = unix2dos[(unsigned char)*p]; + return str; + } else { + for (p = str, dp = cvtbuf; *p; p++,dp++) *dp = unix2dos[(unsigned char)*p]; + *dp = 0; + return cvtbuf; + } } } @@ -126,13 +131,18 @@ char *dos2unix_format(char *str, BOOL overwrite) char *dp; if (!mapsinited) initmaps(); - if (overwrite) { - for (p = str; *p; p++) *p = dos2unix[(unsigned char)*p]; - return str; - } else { - for (p = str, dp = cvtbuf; *p; p++,dp++) *dp = dos2unix[(unsigned char)*p]; - *dp = 0; - return cvtbuf; + + if(lp_client_code_page() == KANJI_CODEPAGE) + return (*_dos_to_unix)(str, overwrite); + else { + if (overwrite) { + for (p = str; *p; p++) *p = dos2unix[(unsigned char)*p]; + return str; + } else { + for (p = str, dp = cvtbuf; *p; p++,dp++) *dp = dos2unix[(unsigned char)*p]; + *dp = 0; + return cvtbuf; + } } } diff --git a/source3/lib/kanji.c b/source3/lib/kanji.c index 479763fd40..f5888e4877 100644 --- a/source3/lib/kanji.c +++ b/source3/lib/kanji.c @@ -23,7 +23,6 @@ and add all jis codes sequence type at 1995.8.16 Notes: Hexadecimal code by <ohki@gssm.otuka.tsukuba.ac.jp> */ -#ifdef KANJI #define _KANJI_C_ #include "includes.h" @@ -888,7 +887,3 @@ int interpret_coding_system(char *str, int def) } return setup_string_function (codes); } -#else - int kanji_dummy_procedure(void) -{return 0;} -#endif /* KANJI */ diff --git a/source3/lib/util.c b/source3/lib/util.c index 7f922def7e..ce0b8bc768 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -813,53 +813,59 @@ int StrCaseCmp(const char *s, const char *t) /* We *must* use toupper rather than tolower here due to the asynchronous upper to lower mapping. */ -#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY) - /* Win95 treats full width ascii characters as case sensitive. */ - int diff; - for (;;) +#if !defined(KANJI_WIN95_COMPATIBILITY) + if(lp_client_code_page() == KANJI_CODEPAGE) { - if (!*s || !*t) - return toupper (*s) - toupper (*t); - else if (is_sj_alph (*s) && is_sj_alph (*t)) - { - diff = sj_toupper2 (*(s+1)) - sj_toupper2 (*(t+1)); - if (diff) - return diff; - s += 2; - t += 2; - } - else if (is_shift_jis (*s) && is_shift_jis (*t)) - { - diff = ((int) (unsigned char) *s) - ((int) (unsigned char) *t); - if (diff) - return diff; - diff = ((int) (unsigned char) *(s+1)) - ((int) (unsigned char) *(t+1)); - if (diff) - return diff; - s += 2; - t += 2; - } - else if (is_shift_jis (*s)) - return 1; - else if (is_shift_jis (*t)) - return -1; - else - { - diff = toupper (*s) - toupper (*t); - if (diff) - return diff; - s++; - t++; - } + /* Win95 treats full width ascii characters as case sensitive. */ + int diff; + for (;;) + { + if (!*s || !*t) + return toupper (*s) - toupper (*t); + else if (is_sj_alph (*s) && is_sj_alph (*t)) + { + diff = sj_toupper2 (*(s+1)) - sj_toupper2 (*(t+1)); + if (diff) + return diff; + s += 2; + t += 2; + } + else if (is_shift_jis (*s) && is_shift_jis (*t)) + { + diff = ((int) (unsigned char) *s) - ((int) (unsigned char) *t); + if (diff) + return diff; + diff = ((int) (unsigned char) *(s+1)) - ((int) (unsigned char) *(t+1)); + if (diff) + return diff; + s += 2; + t += 2; + } + else if (is_shift_jis (*s)) + return 1; + else if (is_shift_jis (*t)) + return -1; + else + { + diff = toupper (*s) - toupper (*t); + if (diff) + return diff; + s++; + t++; + } + } } -#else /* KANJI */ - while (*s && *t && toupper(*s) == toupper(*t)) + else +#endif /* KANJI_WIN95_COMPATIBILITY */ { - s++; t++; - } + while (*s && *t && toupper(*s) == toupper(*t)) + { + s++; + t++; + } - return(toupper(*s) - toupper(*t)); -#endif /* KANJI */ + return(toupper(*s) - toupper(*t)); + } } /******************************************************************* @@ -871,61 +877,69 @@ int StrnCaseCmp(const char *s, const char *t, int n) /* We *must* use toupper rather than tolower here due to the asynchronous upper to lower mapping. */ -#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY) - /* Win95 treats full width ascii characters as case sensitive. */ - int diff; - for (;n > 0;) +#if !defined(KANJI_WIN95_COMPATIBILITY) + if(lp_client_code_page() == KANJI_CODEPAGE) { - if (!*s || !*t) - return toupper (*s) - toupper (*t); - else if (is_sj_alph (*s) && is_sj_alph (*t)) - { - diff = sj_toupper2 (*(s+1)) - sj_toupper2 (*(t+1)); - if (diff) - return diff; - s += 2; - t += 2; - n -= 2; - } - else if (is_shift_jis (*s) && is_shift_jis (*t)) - { - diff = ((int) (unsigned char) *s) - ((int) (unsigned char) *t); - if (diff) - return diff; - diff = ((int) (unsigned char) *(s+1)) - ((int) (unsigned char) *(t+1)); - if (diff) - return diff; - s += 2; - t += 2; - n -= 2; - } - else if (is_shift_jis (*s)) - return 1; - else if (is_shift_jis (*t)) - return -1; - else - { - diff = toupper (*s) - toupper (*t); - if (diff) - return diff; - s++; - t++; - n--; - } + /* Win95 treats full width ascii characters as case sensitive. */ + int diff; + for (;n > 0;) + { + if (!*s || !*t) + return toupper (*s) - toupper (*t); + else if (is_sj_alph (*s) && is_sj_alph (*t)) + { + diff = sj_toupper2 (*(s+1)) - sj_toupper2 (*(t+1)); + if (diff) + return diff; + s += 2; + t += 2; + n -= 2; + } + else if (is_shift_jis (*s) && is_shift_jis (*t)) + { + diff = ((int) (unsigned char) *s) - ((int) (unsigned char) *t); + if (diff) + return diff; + diff = ((int) (unsigned char) *(s+1)) - ((int) (unsigned char) *(t+1)); + if (diff) + return diff; + s += 2; + t += 2; + n -= 2; + } + else if (is_shift_jis (*s)) + return 1; + else if (is_shift_jis (*t)) + return -1; + else + { + diff = toupper (*s) - toupper (*t); + if (diff) + return diff; + s++; + t++; + n--; + } + } + return 0; } - return 0; -#else /* KANJI */ - while (n-- && *s && *t && toupper(*s) == toupper(*t)) + else +#endif /* KANJI_WIN95_COMPATIBILITY */ { - s++; t++; - } + while (n-- && *s && *t && toupper(*s) == toupper(*t)) + { + s++; + t++; + } - /* not run out of chars - strings are different lengths */ - if (n) return(toupper(*s) - toupper(*t)); + /* not run out of chars - strings are different lengths */ + if (n) + return(toupper(*s) - toupper(*t)); - /* identical up to where we run out of chars, and strings are same length */ - return(0); -#endif /* KANJI */ + /* identical up to where we run out of chars, + and strings are same length */ + return(0); + } } /******************************************************************* @@ -968,27 +982,36 @@ BOOL strcsequal(char *s1,char *s2) void strlower(char *s) { while (*s) + { +#if !defined(KANJI_WIN95_COMPATIBILITY) + if(lp_client_code_page() == KANJI_CODEPAGE) + { + /* Win95 treats full width ascii characters as case sensitive. */ + if (is_shift_jis (*s)) + { + if (is_sj_upper (s[0], s[1])) + s[1] = sj_tolower2 (s[1]); + s += 2; + } + else if (is_kana (*s)) + { + s++; + } + else + { + if (isupper(*s)) + *s = tolower(*s); + s++; + } + } + else +#endif /* KANJI_WIN95_COMPATIBILITY */ { -#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY) - /* Win95 treats full width ascii characters as case sensitive. */ - if (is_shift_jis (*s)) { - if (is_sj_upper (s[0], s[1])) { - s[1] = sj_tolower2 (s[1]); - } - s += 2; - } else if (is_kana (*s)) { - s++; - } else { - if (isupper(*s)) - *s = tolower(*s); - s++; - } -#else /* KANJI */ if (isupper(*s)) - *s = tolower(*s); + *s = tolower(*s); s++; -#endif /* KANJI */ } + } } /******************************************************************* @@ -997,27 +1020,36 @@ void strlower(char *s) void strupper(char *s) { while (*s) + { +#if !defined(KANJI_WIN95_COMPATIBILITY) + if(lp_client_code_page() == KANJI_CODEPAGE) + { + /* Win95 treats full width ascii characters as case sensitive. */ + if (is_shift_jis (*s)) + { + if (is_sj_lower (s[0], s[1])) + s[1] = sj_toupper2 (s[1]); + s += 2; + } + else if (is_kana (*s)) + { + s++; + } + else + { + if (islower(*s)) + *s = toupper(*s); + s++; + } + } + else +#endif /* KANJI_WIN95_COMPATIBILITY */ { -#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY) - /* Win95 treats full width ascii characters as case sensitive. */ - if (is_shift_jis (*s)) { - if (is_sj_lower (s[0], s[1])) { - s[1] = sj_toupper2 (s[1]); - } - s += 2; - } else if (is_kana (*s)) { - s++; - } else { - if (islower(*s)) - *s = toupper(*s); - s++; - } -#else /* KANJI */ if (islower(*s)) - *s = toupper(*s); + *s = toupper(*s); s++; -#endif /* KANJI */ } + } } /******************************************************************* @@ -1049,24 +1081,30 @@ BOOL strisnormal(char *s) void string_replace(char *s,char oldc,char newc) { while (*s) + { +#if !defined(KANJI_WIN95_COMPATIBILITY) + if(lp_client_code_page() == KANJI_CODEPAGE) + { + /* Win95 treats full width ascii characters as case sensitive. */ + if (is_shift_jis (*s)) + s += 2; + else if (is_kana (*s)) + s++; + else + { + if (oldc == *s) + *s = newc; + s++; + } + } + else +#endif /* KANJI_WIN95_COMPATIBILITY */ { -#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY) - /* Win95 treats full width ascii characters as case sensitive. */ - if (is_shift_jis (*s)) { - s += 2; - } else if (is_kana (*s)) { - s++; - } else { - if (oldc == *s) - *s = newc; - s++; - } -#else /* KANJI */ if (oldc == *s) - *s = newc; + *s = newc; s++; -#endif /* KANJI */ } + } } /**************************************************************************** @@ -1688,22 +1726,30 @@ does a string have any uppercase chars in it? BOOL strhasupper(char *s) { while (*s) + { +#if !defined(KANJI_WIN95_COMPATIBILITY) + if(lp_client_code_page() == KANJI_CODEPAGE) + { + /* Win95 treats full width ascii characters as case sensitive. */ + if (is_shift_jis (*s)) + s += 2; + else if (is_kana (*s)) + s++; + else + { + if (isupper(*s)) + return(True); + s++; + } + } + else +#endif /* KANJI_WIN95_COMPATIBILITY */ { -#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY) - /* Win95 treats full width ascii characters as case sensitive. */ - if (is_shift_jis (*s)) { - s += 2; - } else if (is_kana (*s)) { - s++; - } else { - if (isupper(*s)) return(True); - s++; - } -#else /* KANJI */ - if (isupper(*s)) return(True); + if (isupper(*s)) + return(True); s++; -#endif /* KANJI */ } + } return(False); } @@ -1713,24 +1759,38 @@ does a string have any lowercase chars in it? BOOL strhaslower(char *s) { while (*s) + { +#if !defined(KANJI_WIN95_COMPATIBILITY) + if(lp_client_code_page() == KANJI_CODEPAGE) { -#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY) - /* Win95 treats full width ascii characters as case sensitive. */ - if (is_shift_jis (*s)) { - if (is_sj_upper (s[0], s[1])) return(True); - if (is_sj_lower (s[0], s[1])) return (True); - s += 2; - } else if (is_kana (*s)) { - s++; - } else { - if (islower(*s)) return(True); - s++; - } -#else /* KANJI */ - if (islower(*s)) return(True); + /* Win95 treats full width ascii characters as case sensitive. */ + if (is_shift_jis (*s)) + { + if (is_sj_upper (s[0], s[1])) + return(True); + if (is_sj_lower (s[0], s[1])) + return (True); + s += 2; + } + else if (is_kana (*s)) + { + s++; + } + else + { + if (islower(*s)) + return(True); + s++; + } + } + else +#endif /* KANJI_WIN95_COMPATIBILITY */ + { + if (islower(*s)) + return(True); s++; -#endif /* KANJI */ } + } return(False); } @@ -1740,27 +1800,33 @@ find the number of chars in a string int count_chars(char *s,char c) { int count=0; -#if defined(KANJI) && !defined(KANJI_WIN95_COMPATIBILITY) - /* Win95 treats full width ascii characters as case sensitive. */ - while (*s) + +#if !defined(KANJI_WIN95_COMPATIBILITY) + if(lp_client_code_page() == KANJI_CODEPAGE) + { + /* Win95 treats full width ascii characters as case sensitive. */ + while (*s) { - if (is_shift_jis (*s)) - s += 2; - else - { - if (*s == c) - count++; - s++; + if (is_shift_jis (*s)) + s += 2; + else + { + if (*s == c) + count++; + s++; + } } } -#else /* KANJI */ - while (*s) + else +#endif /* KANJI_WIN95_COMPATIBILITY */ + { + while (*s) { if (*s == c) - count++; + count++; s++; } -#endif /* KANJI */ + } return(count); } diff --git a/source3/locking/locking.c b/source3/locking/locking.c index f579a75a0b..760d21a05d 100644 --- a/source3/locking/locking.c +++ b/source3/locking/locking.c @@ -616,7 +616,7 @@ BOOL lock_share_entry(int cnum, uint32 dev, uint32 inode, share_lock_token *ptok #ifdef SECURE_SHARE_MODES fd = (share_lock_token)open(fname,O_RDWR|O_CREAT,0600); #else /* SECURE_SHARE_MODES */ - fd = (share_lock_token)open(fname,O_RDWR|O_CREAT,0644); + fd = (share_lock_token)open(fname,O_RDWR|O_CREAT,0666); #endif /* SECURE_SHARE_MODES */ umask(old_umask); if(!become_user(cnum,Connections[cnum].vuid)) diff --git a/source3/namepacket.c b/source3/namepacket.c index d60ef9f6ae..44e449b8c2 100644 --- a/source3/namepacket.c +++ b/source3/namepacket.c @@ -199,11 +199,6 @@ void reply_netbios_packet(struct packet_struct *p1,int trn_id, p = *p1; - if (recursion_available && lp_wins_server()) - { - DEBUG(0,("reply_netbios_packet: r_a not to be used when not a WINS server\n")); - } - switch (rcv_code) { case NMB_STATUS: diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index c3a7581255..047334e143 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -49,6 +49,11 @@ #include "includes.h" +/* Set default coding system for KANJI if none specified in Makefile. */ +#ifndef KANJI +#define KANJI "sjis" +#endif /* KANJI */ + BOOL bLoaded = False; extern int DEBUGLEVEL; @@ -97,9 +102,7 @@ int keepalive=0; extern BOOL use_getwd_cache; extern int extra_time_offset; -#ifdef KANJI extern int coding_system; -#endif /* * This structure describes global (ie., server-wide) parameters. @@ -367,9 +370,7 @@ static BOOL handle_case(char *pszParmValue,int *val); static BOOL handle_printing(char *pszParmValue,int *val); static BOOL handle_character_set(char *pszParmValue,int *val); static BOOL handle_announce_as(char *pszParmValue, int *val); -#ifdef KANJI static BOOL handle_coding_system(char *pszParmValue,int *val); -#endif /* KANJI */ static void set_default_server_announce_type(void); @@ -452,9 +453,7 @@ struct parm_struct {"read size", P_INTEGER, P_GLOBAL, &Globals.ReadSize, NULL}, {"shared mem size", P_INTEGER, P_GLOBAL, &Globals.shmem_size, NULL}, {"shared file entries", P_INTEGER, P_GLOBAL, &Globals.shmem_hash_size, NULL}, -#ifdef KANJI {"coding system", P_INTEGER, P_GLOBAL, &coding_system, handle_coding_system}, -#endif /* KANJI */ {"client code page", P_INTEGER, P_GLOBAL, &Globals.client_code_page, NULL}, {"os level", P_INTEGER, P_GLOBAL, &Globals.os_level, NULL}, {"max ttl", P_INTEGER, P_GLOBAL, &Globals.max_ttl, NULL}, @@ -646,9 +645,7 @@ static void init_globals(void) Globals.bNISHomeMap = False; string_set(&Globals.szNISHomeMapName, "auto.home"); #endif -#ifdef KANJI coding_system = interpret_coding_system (KANJI, SJIS_CODE); -#endif /* KANJI */ Globals.client_code_page = DEFAULT_CLIENT_CODE_PAGE; Globals.bTimeServer = False; @@ -1418,7 +1415,6 @@ BOOL lp_file_list_changed(void) return(False); } -#ifdef KANJI /*************************************************************************** handle the interpretation of the coding system parameter *************************************************************************/ @@ -1427,7 +1423,6 @@ static BOOL handle_coding_system(char *pszParmValue,int *val) *val = interpret_coding_system(pszParmValue,*val); return(True); } -#endif /* KANJI */ /*************************************************************************** handle the interpretation of the character set system parameter diff --git a/source3/smbd/mangle.c b/source3/smbd/mangle.c index a08402a85e..3f753cf855 100644 --- a/source3/smbd/mangle.c +++ b/source3/smbd/mangle.c @@ -123,30 +123,34 @@ BOOL is_8_3(char *fname, BOOL check_case) { char *p = fname; -#ifdef KANJI - dot_pos = 0; - while (*p) + if(lp_client_code_page() == KANJI_CODEPAGE) + { + dot_pos = 0; + while (*p) { - if (is_shift_jis (*p)) { - p += 2; - } else if (is_kana (*p)) { - p ++; - } else { - if (*p == '.' && !dot_pos) - dot_pos = (char *) p; - if (!isdoschar(*p)) - return(False); - p++; - } - } -#else - while (*p) + if (is_shift_jis (*p)) + p += 2; + else if (is_kana (*p)) + p ++; + else + { + if (*p == '.' && !dot_pos) + dot_pos = (char *) p; + if (!isdoschar(*p)) + return(False); + p++; + } + } + } + else + { + while (*p) { - if (!isdoschar(*p)) - return(False); - p++; + if (!isdoschar(*p)) + return(False); + p++; } -#endif /* KANJI */ + } } /* no dot and less than 9 means OK */ @@ -498,84 +502,90 @@ void mangle_name_83(char *s) DEBUG(5,("Mangling name %s to ",s)); if (p) - { - if (p == s) - strcpy(extension,"___"); - else + { + if (p == s) + strcpy(extension,"___"); + else { *p++ = 0; while (*p && extlen < 3) - { -#ifdef KANJI - if (is_shift_jis (*p)) - { - if (extlen < 2) - { - extension[extlen++] = p[0]; - extension[extlen++] = p[1]; - } - else - { - extension[extlen++] = base36 (((unsigned char) *p) % 36); - } - p += 2; - } - else if (is_kana (*p)) - { - extension[extlen++] = p[0]; - p++; - } - else - { - if (isdoschar (*p) && *p != '.') - extension[extlen++] = p[0]; - p++; - } -#else - if (isdoschar(*p) && *p != '.') - extension[extlen++] = *p; - p++; -#endif /* KANJI */ - } + { + if(lp_client_code_page() == KANJI_CODEPAGE) + { + if (is_shift_jis (*p)) + { + if (extlen < 2) + { + extension[extlen++] = p[0]; + extension[extlen++] = p[1]; + } + else + { + extension[extlen++] = base36 (((unsigned char) *p) % 36); + } + p += 2; + } + else if (is_kana (*p)) + { + extension[extlen++] = p[0]; + p++; + } + else + { + if (isdoschar (*p) && *p != '.') + extension[extlen++] = p[0]; + p++; + } + } + else + { + if (isdoschar(*p) && *p != '.') + extension[extlen++] = *p; + p++; + } + } extension[extlen] = 0; - } } + } p = s; while (*p && baselen < 5) + { + if(lp_client_code_page() == KANJI_CODEPAGE) { -#ifdef KANJI if (is_shift_jis (*p)) - { - if (baselen < 4) - { - base[baselen++] = p[0]; - base[baselen++] = p[1]; - } - else - { + { + if (baselen < 4) + { + base[baselen++] = p[0]; + base[baselen++] = p[1]; + } + else + { base[baselen++] = base36 (((unsigned char) *p) % 36); - } - p += 2; - } + } + p += 2; + } else if (is_kana (*p)) - { - base[baselen++] = p[0]; - p++; - } + { + base[baselen++] = p[0]; + p++; + } else - { - if (isdoschar (*p) && *p != '.') - base[baselen++] = p[0]; - p++; - } -#else + { + if (isdoschar (*p) && *p != '.') + base[baselen++] = p[0]; + p++; + } + } + else + { if (isdoschar(*p) && *p != '.') - base[baselen++] = *p; + base[baselen++] = *p; p++; -#endif /* KANJI */ } + } base[baselen] = 0; csum = csum % (36*36); @@ -601,7 +611,8 @@ static BOOL illegal_name(char *name) static BOOL initialised=False; unsigned char *s; - if (!initialised) { + if (!initialised) + { char *ill = "*\\/?<>|\":{}"; initialised = True; @@ -610,21 +621,23 @@ static BOOL illegal_name(char *name) illegal[*s] = True; } -#ifdef KANJI - for (s = (unsigned char *)name; *s;) { - if (is_shift_jis (*s)) { - s += 2; - } else if (illegal[*s]) { - return(True); - } else { - s++; + if(lp_client_code_page() == KANJI_CODEPAGE) + { + for (s = (unsigned char *)name; *s;) { + if (is_shift_jis (*s)) { + s += 2; + } else if (illegal[*s]) { + return(True); + } else { + s++; + } } } -#else - for (s = (unsigned char *)name;*s;s++) - if (illegal[*s]) return(True); -#endif - + else + { + for (s = (unsigned char *)name;*s;s++) + if (illegal[*s]) return(True); + } return(False); } diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 19c1158658..c8e726d36e 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -1347,6 +1347,14 @@ static int call_trans2setfilepathinfo(char *inbuf, char *outbuf, int length, tvs.modtime=MAX(interpret_long_date(pdata+16), interpret_long_date(pdata+24)); +#if 0 /* Needs more testing... */ + /* Test from Luke to prevent Win95 from + setting incorrect values here. + */ + if (tvs.actime < tvs.modtime) + return(ERROR(ERRDOS,ERRnoaccess)); +#endif /* Needs more testing... */ + /* attributes */ mode = IVAL(pdata,32); break; diff --git a/source3/utils/nmblookup.c b/source3/utils/nmblookup.c index 582f4eb6db..25c94dcd6a 100644 --- a/source3/utils/nmblookup.c +++ b/source3/utils/nmblookup.c @@ -192,17 +192,25 @@ int main(int argc,char *argv[]) retries = 1; } - if (name_query(ServerFD,lookup,lookup_type,bcast,True, + if (name_query(ServerFD,lookup,lookup_type,bcast,True, bcast_addr,&ip,NULL)) - { - printf("%s %s\n",inet_ntoa(ip),lookup); - } + { + printf("%s %s\n",inet_ntoa(ip),lookup); + + /* We can only do find_status if the ip address returned + was valid - ie. name_query returned true. + */ if (find_status) { printf("Looking up status of %s\n",inet_ntoa(ip)); name_status(ServerFD,lookup,lookup_type,True,ip,NULL,NULL,NULL); printf("\n"); } + } + else + { + printf("name_query failed to find name %s\n", lookup); + } } return(0); |