1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-01 05:47:28 +03:00
samba-mirror/source/lib/charset.c
Andrew Tridgell 5aa735c940 - changed the umask handling. We now set the umask to 0 and explicitly
set the mode on all created files. I think this is a better policy.

- change the debug levels on some items

- fix a charset handling bug which affected foreign and extended
charset users

- no longer switch back to the original directory when idle, instead
switch to / as the original directory may not be readable by ordinary
users.

- fix some bugs where the create mode of files was not being
explicitly set (it was relying on the umask and using fopen). Not a
big bug as it only affected obscure commands like the messaging ops.

- got rid of the lock code in the lpq cache as its no longer needed

- rewrote smbrun to be faster and to remove the security hole. We now
don't actually need a external smbrun binary, its all done by smbd.

- add a more explicit warning about uids and gids of -1 or 65535
-

114 lines
3.4 KiB
C

/*
Unix SMB/Netbios implementation.
Version 1.9.
Character set handling
Copyright (C) Andrew Tridgell 1992-1995
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#define CHARSET_C
#include "includes.h"
extern int DEBUGLEVEL;
char xx_dos_char_map[256];
char xx_upper_char_map[256];
char xx_lower_char_map[256];
char *dos_char_map = NULL;
char *upper_char_map = NULL;
char *lower_char_map = NULL;
static void add_dos_char(int lower, int upper)
{
DEBUG(6,("Adding chars 0%o 0%o\n",lower,upper));
if (lower) dos_char_map[(char)lower] = 1;
if (upper) dos_char_map[(char)upper] = 1;
if (lower && upper) {
lower_char_map[(char)upper] = (char)lower;
upper_char_map[(char)lower] = (char)upper;
lower_char_map[(char)lower] = (char)lower;
upper_char_map[(char)upper] = (char)upper;
}
}
/****************************************************************************
initialise the charset arrays
****************************************************************************/
void charset_initialise(void)
{
int i;
dos_char_map = &xx_dos_char_map[128];
upper_char_map = &xx_upper_char_map[128];
lower_char_map = &xx_lower_char_map[128];
for (i= -128;i<=127;i++) {
dos_char_map[(char)i] = 0;
}
for (i=0;i<=127;i++) {
if (isalnum((char)i) || strchr("._^$~!#%&-{}()@'`",(char)i))
add_dos_char(i,0);
}
for (i= -128;i<=127;i++) {
char c = (char)i;
upper_char_map[i] = lower_char_map[i] = c;
if (isupper(c)) lower_char_map[c] = tolower(c);
if (islower(c)) upper_char_map[c] = toupper(c);
}
/* valid for all DOS PC */
add_dos_char(142,0); /* A trema */
add_dos_char(143,0); /* A o */
add_dos_char(144,0); /* E ' */
add_dos_char(146,0); /* AE */
add_dos_char(153,0); /* O trema */
add_dos_char(154,0); /* U trema */
add_dos_char(165,0); /* N tilda */
add_dos_char(128,0); /* C cedille */
add_dos_char(156,0); /* Pound */
add_dos_char(183,0); /* A ` (WIN)*/
add_dos_char(157,0); /* Phi (WIN)*/
add_dos_char(212,0); /* E` (WIN)*/
}
/*******************************************************************
add characters depending on a string passed by the user
********************************************************************/
void add_char_string(char *s)
{
char *extra_chars = (char *)strdup(s);
char *t;
if (!extra_chars) return;
for (t=strtok(extra_chars," \t\r\n"); t; t=strtok(NULL," \t\r\n")) {
char c1=0,c2=0;
int i1=0,i2=0;
if (isdigit(*t) || (*t)=='-') {
sscanf(t,"%i:%i",&i1,&i2);
add_dos_char(i1,i2);
} else {
sscanf(t,"%c:%c",&c1,&c2);
add_dos_char(c1,c2);
}
}
free(extra_chars);
}