diff options
author | Andrew Tridgell <tridge@samba.org> | 1997-09-14 16:37:18 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 1997-09-14 16:37:18 +0000 |
commit | 33a003de4056532be0c9a199d4857b9da1b18034 (patch) | |
tree | 69362f80d2ff1db2d79bd218701f5cff2320f8ed | |
parent | 58ec10049b8029de82e70ba10559e143a1b16707 (diff) | |
download | samba-33a003de4056532be0c9a199d4857b9da1b18034.tar.gz samba-33a003de4056532be0c9a199d4857b9da1b18034.tar.bz2 samba-33a003de4056532be0c9a199d4857b9da1b18034.zip |
This commit does 3 main things:
1) put the encryption code in by default, with no #ifdef. It is still
disabled by default so you need to add "encrypt passwords = yes" in
smb.conf but at least all binaries will have it.
2) cleanup the kanji code so it compiles with no warnings
3) get rid of lots of uses of ugly non-portable C code. The main
offender being things like "register" but also remove uses of the
"const" keyword as there are compilers out there that don't support it
and even those that do often complain about its usage. Users don't
like warnings :-(
There is still some work to do. We need to replace the md4 code with
our own implementation. The current code (from rfc1186) is PD but is
not very portable. The new RFC (rfc1320) is more portable but adds
copyright restrictions. I'll do a from-scratch MD4 soon.
We also need to test that what I've implemented is portable. It should
be, but I'm too tired right now to test it on anything other than
intel linux.
(This used to be commit db917c62c14315afe6f0745a8097c1bca25cbf07)
-rw-r--r-- | source3/client/client.c | 6 | ||||
-rw-r--r-- | source3/client/clientutil.c | 6 | ||||
-rw-r--r-- | source3/include/kanji.h | 9 | ||||
-rw-r--r-- | source3/include/proto.h | 30 | ||||
-rw-r--r-- | source3/include/smb.h | 4 | ||||
-rw-r--r-- | source3/lib/getsmbpass.c | 4 | ||||
-rw-r--r-- | source3/lib/kanji.c | 99 | ||||
-rw-r--r-- | source3/lib/md4.c | 4 | ||||
-rw-r--r-- | source3/lib/system.c | 3 | ||||
-rw-r--r-- | source3/lib/util.c | 10 | ||||
-rw-r--r-- | source3/libsmb/nmblib.c | 6 | ||||
-rw-r--r-- | source3/libsmb/smbencrypt.c | 73 | ||||
-rw-r--r-- | source3/param/loadparm.c | 4 | ||||
-rw-r--r-- | source3/passdb/smbpass.c | 6 | ||||
-rw-r--r-- | source3/smbd/ipc.c | 2 | ||||
-rw-r--r-- | source3/smbd/password.c | 31 | ||||
-rw-r--r-- | source3/smbd/server.c | 12 | ||||
-rw-r--r-- | source3/utils/make_smbcodepage.c | 6 | ||||
-rw-r--r-- | source3/utils/smbpasswd.c | 14 | ||||
-rw-r--r-- | source3/wsmbconf.c | 2 |
20 files changed, 96 insertions, 235 deletions
diff --git a/source3/client/client.c b/source3/client/client.c index e9042555e2..da4acbb855 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -3303,15 +3303,11 @@ static BOOL send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setu int passlen = strlen(pass)+1; strcpy(pword,pass); -#ifdef SMB_PASSWD if (doencrypt && *pass) { DEBUG(3,("Using encrypted passwords\n")); passlen = 24; SMBencrypt((uchar *)pass,(uchar *)cryptkey,(uchar *)pword); } -#else - doencrypt = False; -#endif /* if in share level security then don't send a password now */ if (!(sec_mode & 1)) {strcpy(pword, "");passlen=1;} @@ -3422,12 +3418,10 @@ static BOOL send_login(char *inbuf,char *outbuf,BOOL start_session,BOOL use_setu fstring pword; strcpy(pword,pass); -#ifdef SMB_PASSWD if (doencrypt && *pass) { passlen=24; SMBencrypt((uchar *)pass,(uchar *)cryptkey,(uchar *)pword); } -#endif /* if in user level security then don't send a password now */ if ((sec_mode & 1)) { diff --git a/source3/client/clientutil.c b/source3/client/clientutil.c index b4f0849c5f..07c340ccac 100644 --- a/source3/client/clientutil.c +++ b/source3/client/clientutil.c @@ -440,15 +440,11 @@ BOOL cli_send_login(char *inbuf, char *outbuf, BOOL start_session, BOOL use_setu int passlen = strlen(pass)+1; strcpy(pword,pass); -#ifdef SMB_PASSWD if (doencrypt && *pass) { DEBUG(5,("Using encrypted passwords\n")); passlen = 24; SMBencrypt((uchar *)pass,(uchar *)cryptkey,(uchar *)pword); } -#else - doencrypt = False; -#endif /* if in share level security then don't send a password now */ if (!(sec_mode & 1)) {strcpy(pword, "");passlen=1;} @@ -559,12 +555,10 @@ BOOL cli_send_login(char *inbuf, char *outbuf, BOOL start_session, BOOL use_setu fstring pword; strcpy(pword,pass); -#ifdef SMB_PASSWD if (doencrypt && *pass) { passlen=24; SMBencrypt((uchar *)pass,(uchar *)cryptkey,(uchar *)pword); } -#endif /* if in user level security then don't send a password now */ if ((sec_mode & 1)) { diff --git a/source3/include/kanji.h b/source3/include/kanji.h index 1d2359baa9..cf30365920 100644 --- a/source3/include/kanji.h +++ b/source3/include/kanji.h @@ -105,13 +105,8 @@ #else /* not _KANJI_C_ */ -extern char* (*_dos_to_unix) (const char *str, BOOL overwrite); -extern char* (*_unix_to_dos) (const char *str, BOOL overwrite); - -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); -extern char *sj_strstr (const char *s1, const char *s2); +extern char *(*_dos_to_unix)(char *str, BOOL overwrite); +extern char *(*_unix_to_dos)(char *str, BOOL overwrite); #define strchr sj_strchr #define strrchr sj_strrchr diff --git a/source3/include/proto.h b/source3/include/proto.h index 755ead7a52..12aae2b2d2 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -120,6 +120,10 @@ int reply_trans(char *inbuf,char *outbuf); /*The following definitions come from kanji.c */ +char *sj_strtok(char *s1, char *s2); +char *sj_strstr(char *s1, char *s2); +char *sj_strchr (char *s, int c); +char *sj_strrchr(char *s, int c); int interpret_coding_system(char *str, int def); /*The following definitions come from loadparm.c */ @@ -309,14 +313,14 @@ BOOL set_share_mode(share_lock_token token,int fnum); /*The following definitions come from make_smbcodepage.c */ -void codepage_usage(const char *progname); +void codepage_usage(char *progname); void read_line( char **buf, char *line_buf, int size); int clean_data( char **buf, uint32 *size); BOOL parse_byte(char *buf, unsigned char *bp); BOOL parse_bool(char *buf, unsigned char *bp); void parse_error(char *buf, char *msg); -int do_compile(int codepage, const char *input_file, const char *output_file); -int do_decompile( int codepage, const char *input_file, const char *output_file); +int do_compile(int codepage, char *input_file, char *output_file); +int do_decompile( int codepage, char *input_file, char *output_file); int main(int argc, char **argv); /*The following definitions come from mangle.c */ @@ -565,6 +569,7 @@ BOOL reload_services(BOOL test); /*The following definitions come from nmblib.c */ +char *lookup_opcode_name( int opcode ); void debug_nmb_packet(struct packet_struct *p); char *namestr(struct nmb_name *n); void free_nmb_packet(struct nmb_packet *nmb); @@ -778,10 +783,12 @@ BOOL smb_shm_get_usage(int *bytes_free, int *bytes_used, int *bytes_overhead); +/*The following definitions come from smbdes.c */ + +void smbdes(unsigned char *out, unsigned char *in, unsigned char *key); + /*The following definitions come from smbencrypt.c */ -void str_to_key(uchar *str,uchar *key); -void D1(uchar *k, uchar *d, uchar *out); void E1(uchar *k, uchar *d, uchar *out); void E_P16(uchar *p14,uchar *p16); void E_P24(uchar *p21, uchar *c8, uchar *p24); @@ -801,6 +808,9 @@ struct smb_passwd *get_smbpwnam(char *name); /*The following definitions come from smbrun.c */ +/*The following definitions come from smbwizard.c */ + + /*The following definitions come from status.c */ void Ucrit_addUsername(pstring username); @@ -901,10 +911,10 @@ time_t file_modtime(char *fname); BOOL directory_exist(char *dname,struct stat *st); uint32 file_size(char *file_name); char *attrib_string(int mode); -int StrCaseCmp(const char *s, const char *t); -int StrnCaseCmp(const char *s, const char *t, int n); -BOOL strequal(const char *s1, const char *s2); -BOOL strnequal(const char *s1,const char *s2,int n); +int StrCaseCmp(char *s, char *t); +int StrnCaseCmp(char *s, char *t, int n); +BOOL strequal(char *s1, char *s2); +BOOL strnequal(char *s1,char *s2,int n); BOOL strcsequal(char *s1,char *s2); void strlower(char *s); void strupper(char *s); @@ -997,7 +1007,7 @@ void free_namearray(name_compare_entry *name_array); BOOL fcntl_lock(int fd,int op,uint32 offset,uint32 count,int type); int file_lock(char *name,int timeout); void file_unlock(int fd); -BOOL is_myname(const char *s); +BOOL is_myname(char *s); void set_remote_arch(enum remote_arch_types type); enum remote_arch_types get_remote_arch(); diff --git a/source3/include/smb.h b/source3/include/smb.h index 47fbf32f83..6ef0e6f9d0 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -526,11 +526,7 @@ struct connect_record #define IS_HIDDEN_PATH(cnum,path) (is_in_path((path),Connections[(cnum)].hide_list)) #define IS_VETO_PATH(cnum,path) (is_in_path((path),Connections[(cnum)].veto_list)) -#ifdef SMB_PASSWD #define SMBENCRYPT() (lp_encrypted_passwords()) -#else -#define SMBENCRYPT() (False) -#endif /* the basic packet size, assuming no words or bytes */ #define smb_size 39 diff --git a/source3/lib/getsmbpass.c b/source3/lib/getsmbpass.c index 9008d40f91..e8cb683d0b 100644 --- a/source3/lib/getsmbpass.c +++ b/source3/lib/getsmbpass.c @@ -45,7 +45,7 @@ static struct termio t; return ioctl(fd, TCGETA, t); } - int tcsetattr(int fd, int flags, const struct termio *t) + int tcsetattr(int fd, int flags, struct termio *t) { if(flags & TCSAFLUSH) ioctl(fd, TCFLSH, TCIOFLUSH); @@ -76,7 +76,7 @@ static struct sgttyb t; return ioctl(fd, TIOCGETP, (char *)t); } - int tcsetattr(int fd, int flags, const struct sgttyb *t) + int tcsetattr(int fd, int flags, struct sgttyb *t) { return ioctl(fd, TIOCSETP, (char *)t); } diff --git a/source3/lib/kanji.c b/source3/lib/kanji.c index f5888e4877..5d7de87248 100644 --- a/source3/lib/kanji.c +++ b/source3/lib/kanji.c @@ -42,8 +42,7 @@ char hex_tag = HEXTAG; search token from S1 separated any char of S2 S1 contain SHIFT JIS chars. ********************************************************************/ -char * -sj_strtok (char *s1, const char *s2) +char *sj_strtok(char *s1, char *s2) { static char *s = NULL; char *q; @@ -82,10 +81,9 @@ sj_strtok (char *s1, const char *s2) search string S2 from S1 S1 contain SHIFT JIS chars. ********************************************************************/ -char * -sj_strstr (const char *s1, const char *s2) +char *sj_strstr(char *s1, char *s2) { - register int len = strlen ((char *) s2); + int len = strlen ((char *) s2); if (!*s2) return (char *) s1; for (;*s1;) { @@ -106,8 +104,7 @@ sj_strstr (const char *s1, const char *s2) Search char C from beginning of S. S contain SHIFT JIS chars. ********************************************************************/ -char * -sj_strchr (const char *s, int c) +char *sj_strchr (char *s, int c) { for (; *s; ) { if (*s == c) @@ -125,10 +122,9 @@ sj_strchr (const char *s, int c) Search char C end of S. S contain SHIFT JIS chars. ********************************************************************/ -char * -sj_strrchr (const char *s, int c) +char *sj_strrchr(char *s, int c) { - register char *q; + char *q; for (q = 0; *s; ) { if (*s == c) { @@ -152,8 +148,7 @@ static char cvtbuf[1024]; /******************************************************************* EUC <-> SJIS ********************************************************************/ -static int -euc2sjis (register int hi, register int lo) +static int euc2sjis (int hi, int lo) { if (hi & 1) return ((hi / 2 + (hi < 0xdf ? 0x31 : 0x71)) << 8) | @@ -162,8 +157,7 @@ euc2sjis (register int hi, register int lo) return ((hi / 2 + (hi < 0xdf ? 0x30 : 0x70)) << 8) | (lo - 2); } -static int -sjis2euc (register int hi, register int lo) +static int sjis2euc (int hi, int lo) { if (lo >= 0x9f) return ((hi * 2 - (hi >= 0xe0 ? 0xe0 : 0x60)) << 8) | (lo + 2); @@ -176,10 +170,9 @@ sjis2euc (register int hi, register int lo) Convert FROM contain SHIFT JIS codes to EUC codes return converted buffer ********************************************************************/ -static char * -sj_to_euc (const char *from, BOOL overwrite) +static char *sj_to_euc(char *from, BOOL overwrite) { - register char *out; + char *out; char *save; save = (char *) from; @@ -209,10 +202,9 @@ sj_to_euc (const char *from, BOOL overwrite) Convert FROM contain EUC codes to SHIFT JIS codes return converted buffer ********************************************************************/ -static char * -euc_to_sj (const char *from, BOOL overwrite) +static char *euc_to_sj(char *from, BOOL overwrite) { - register char *out; + char *out; char *save; save = (char *) from; @@ -241,8 +233,7 @@ euc_to_sj (const char *from, BOOL overwrite) /******************************************************************* JIS7,JIS8,JUNET <-> SJIS ********************************************************************/ -static int -sjis2jis (register int hi, register int lo) +static int sjis2jis(int hi, int lo) { if (lo >= 0x9f) return ((hi * 2 - (hi >= 0xe0 ? 0x160 : 0xe0)) << 8) | (lo - 0x7e); @@ -251,8 +242,7 @@ sjis2jis (register int hi, register int lo) (lo - (lo >= 0x7f ? 0x20 : 0x1f)); } -static int -jis2sjis (register int hi, register int lo) +static int jis2sjis(int hi, int lo) { if (hi & 1) return ((hi / 2 + (hi < 0x5f ? 0x71 : 0xb1)) << 8) | @@ -265,11 +255,10 @@ jis2sjis (register int hi, register int lo) Convert FROM contain JIS codes to SHIFT JIS codes return converted buffer ********************************************************************/ -static char * -jis8_to_sj (const char *from, BOOL overwrite) +static char *jis8_to_sj(char *from, BOOL overwrite) { - register char *out; - register int shifted; + char *out; + int shifted; char *save; shifted = _KJ_ROMAN; @@ -316,11 +305,10 @@ jis8_to_sj (const char *from, BOOL overwrite) Convert FROM contain SHIFT JIS codes to JIS codes return converted buffer ********************************************************************/ -static char * -sj_to_jis8 (const char *from, BOOL overwrite) +static char *sj_to_jis8(char *from, BOOL overwrite) { - register char *out; - register int shifted; + char *out; + int shifted; char *save; shifted = _KJ_ROMAN; @@ -373,11 +361,10 @@ sj_to_jis8 (const char *from, BOOL overwrite) Convert FROM contain 7 bits JIS codes to SHIFT JIS codes return converted buffer ********************************************************************/ -static char * -jis7_to_sj (const char *from, BOOL overwrite) +static char *jis7_to_sj(char *from, BOOL overwrite) { - register char *out; - register int shifted; + char *out; + int shifted; char *save; shifted = _KJ_ROMAN; @@ -433,11 +420,10 @@ jis7_to_sj (const char *from, BOOL overwrite) Convert FROM contain SHIFT JIS codes to 7 bits JIS codes return converted buffer ********************************************************************/ -static char * -sj_to_jis7 (const char *from, BOOL overwrite) +static char *sj_to_jis7(char *from, BOOL overwrite) { - register char *out; - register int shifted; + char *out; + int shifted; char *save; shifted = _KJ_ROMAN; @@ -510,11 +496,10 @@ sj_to_jis7 (const char *from, BOOL overwrite) Convert FROM contain 7 bits JIS(junet) codes to SHIFT JIS codes return converted buffer ********************************************************************/ -static char * -junet_to_sj (const char *from, BOOL overwrite) +static char *junet_to_sj(char *from, BOOL overwrite) { - register char *out; - register int shifted; + char *out; + int shifted; char *save; shifted = _KJ_ROMAN; @@ -567,11 +552,10 @@ junet_to_sj (const char *from, BOOL overwrite) Convert FROM contain SHIFT JIS codes to 7 bits JIS(junet) codes return converted buffer ********************************************************************/ -static char * -sj_to_junet (const char *from, BOOL overwrite) +static char *sj_to_junet(char *from, BOOL overwrite) { - register char *out; - register int shifted; + char *out; + int shifted; char *save; shifted = _KJ_ROMAN; @@ -637,8 +621,7 @@ sj_to_junet (const char *from, BOOL overwrite) HEX <-> SJIS ********************************************************************/ /* ":xx" -> a byte */ -static char * -hex_to_sj (const char *from, BOOL overwrite) +static char *hex_to_sj(char *from, BOOL overwrite) { char *sp, *dp; @@ -663,8 +646,7 @@ hex_to_sj (const char *from, BOOL overwrite) /******************************************************************* kanji/kana -> ":xx" ********************************************************************/ -static char * -sj_to_hex (const char *from, BOOL overwrite) +static char *sj_to_hex(char *from, BOOL overwrite) { unsigned char *sp, *dp; @@ -700,8 +682,7 @@ sj_to_hex (const char *from, BOOL overwrite) /******************************************************************* kanji/kana -> ":xx" ********************************************************************/ -static char * -sj_to_cap (const char *from, BOOL overwrite) +static char *sj_to_cap(char *from, BOOL overwrite) { unsigned char *sp, *dp; @@ -729,8 +710,7 @@ sj_to_cap (const char *from, BOOL overwrite) /******************************************************************* sj to sj ********************************************************************/ -static char * -sj_to_sj (const char *from, BOOL overwrite) +static char *sj_to_sj(char *from, BOOL overwrite) { if (!overwrite) { strcpy (cvtbuf, (char *) from); @@ -745,11 +725,10 @@ sj_to_sj (const char *from, BOOL overwrite) _dos_to_unix _unix_to_dos ************************************************************************/ -char* (*_dos_to_unix) (const char *str, BOOL overwrite) = sj_to_sj; -char* (*_unix_to_dos) (const char *str, BOOL overwrite) = sj_to_sj; +char *(*_dos_to_unix)(char *str, BOOL overwrite) = sj_to_sj; +char *(*_unix_to_dos)(char *str, BOOL overwrite) = sj_to_sj; -static int -setup_string_function (int codes) +static int setup_string_function(int codes) { switch (codes) { default: diff --git a/source3/lib/md4.c b/source3/lib/md4.c index bdff075c7e..87aafce802 100644 --- a/source3/lib/md4.c +++ b/source3/lib/md4.c @@ -1,4 +1,3 @@ -#ifdef SMB_PASSWD /* This code is from rfc1186. */ @@ -294,6 +293,3 @@ /* ** End of md4.c */ -#else - void md4_dummy() {;} -#endif diff --git a/source3/lib/system.c b/source3/lib/system.c index 447a4f88ac..c539b25883 100644 --- a/source3/lib/system.c +++ b/source3/lib/system.c @@ -202,8 +202,7 @@ for rename across filesystems Patch from Warren Birnbaum <warrenb@hpcvscdp.cv.hp.com> **********************************************************/ -static int -copy_reg (const char *source, const char *dest) +static int copy_reg(char *source, const char *dest) { struct stat source_stats; int ifd; diff --git a/source3/lib/util.c b/source3/lib/util.c index ce0b8bc768..b0213912d1 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -807,7 +807,7 @@ char *attrib_string(int mode) /******************************************************************* case insensitive string compararison ********************************************************************/ -int StrCaseCmp(const char *s, const char *t) +int StrCaseCmp(char *s, char *t) { /* compare until we run out of string, either t or s, or find a difference */ /* We *must* use toupper rather than tolower here due to the @@ -871,7 +871,7 @@ int StrCaseCmp(const char *s, const char *t) /******************************************************************* case insensitive string compararison, length limited ********************************************************************/ -int StrnCaseCmp(const char *s, const char *t, int n) +int StrnCaseCmp(char *s, char *t, int 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 @@ -945,7 +945,7 @@ int StrnCaseCmp(const char *s, const char *t, int n) /******************************************************************* compare 2 strings ********************************************************************/ -BOOL strequal(const char *s1, const char *s2) +BOOL strequal(char *s1, char *s2) { if (s1 == s2) return(True); if (!s1 || !s2) return(False); @@ -956,7 +956,7 @@ BOOL strequal(const char *s1, const char *s2) /******************************************************************* compare 2 strings up to and including the nth char. ******************************************************************/ -BOOL strnequal(const char *s1,const char *s2,int n) +BOOL strnequal(char *s1,char *s2,int n) { if (s1 == s2) return(True); if (!s1 || !s2 || !n) return(False); @@ -3923,7 +3923,7 @@ void file_unlock(int fd) is the name specified one of my netbios names returns true is it is equal, false otherwise ********************************************************************/ -BOOL is_myname(const char *s) +BOOL is_myname(char *s) { int n; BOOL ret = False; diff --git a/source3/libsmb/nmblib.c b/source3/libsmb/nmblib.c index bc967bdacb..456a8218d8 100644 --- a/source3/libsmb/nmblib.c +++ b/source3/libsmb/nmblib.c @@ -31,8 +31,8 @@ extern pstring myname; extern struct in_addr ipzero; static struct opcode_names { - const char *nmb_opcode_name; - int opcode; + char *nmb_opcode_name; + int opcode; } nmb_header_opcode_names[] = { { "Query", 0 }, {"Registration", 5 }, @@ -46,7 +46,7 @@ static struct opcode_names { * Lookup a nmb opcode name. ****************************************************************************/ -const char *lookup_opcode_name( int opcode ) +char *lookup_opcode_name( int opcode ) { struct opcode_names *op_namep; int i; diff --git a/source3/libsmb/smbencrypt.c b/source3/libsmb/smbencrypt.c index 8bb21cfed2..b2ae363952 100644 --- a/source3/libsmb/smbencrypt.c +++ b/source3/libsmb/smbencrypt.c @@ -1,4 +1,3 @@ -#ifdef SMB_PASSWD /* Unix SMB/Netbios implementation. Version 1.9. @@ -22,81 +21,32 @@ */ #include "includes.h" -#include "des.h" #include "md4.h" extern int DEBUGLEVEL; #include "byteorder.h" -void str_to_key(uchar *str,uchar *key) -{ - void des_set_odd_parity(des_cblock *); - int i; - - key[0] = str[0]>>1; - key[1] = ((str[0]&0x01)<<6) | (str[1]>>2); - key[2] = ((str[1]&0x03)<<5) | (str[2]>>3); - key[3] = ((str[2]&0x07)<<4) | (str[3]>>4); - key[4] = ((str[3]&0x0F)<<3) | (str[4]>>5); - key[5] = ((str[4]&0x1F)<<2) | (str[5]>>6); - key[6] = ((str[5]&0x3F)<<1) | (str[6]>>7); - key[7] = str[6]&0x7F; - for (i=0;i<8;i++) { - key[i] = (key[i]<<1); - } - des_set_odd_parity((des_cblock *)key); -} - -void D1(uchar *k, uchar *d, uchar *out) -{ - des_key_schedule ks; - des_cblock deskey; - - str_to_key(k,(uchar *)deskey); -#ifdef __FreeBSD__ - des_set_key(&deskey,ks); -#else /* __FreeBSD__ */ - des_set_key((des_cblock *)deskey,ks); -#endif /* __FreeBsd */ - des_ecb_encrypt((des_cblock *)d,(des_cblock *)out, ks, DES_DECRYPT); -} - void E1(uchar *k, uchar *d, uchar *out) { - des_key_schedule ks; - des_cblock deskey; - - str_to_key(k,(uchar *)deskey); -#ifdef __FreeBSD__ - des_set_key(&deskey,ks); -#else /* __FreeBsd__ */ - des_set_key((des_cblock *)deskey,ks); -#endif /* __FreeBsd__ */ - des_ecb_encrypt((des_cblock *)d,(des_cblock *)out, ks, DES_ENCRYPT); + smbdes(out, d, k); } void E_P16(uchar *p14,uchar *p16) { - uchar sp7[7]; - /* the following constant makes us compatible with other - implementations. Note that publishing this constant does not reduce the - security of the encryption mechanism */ - uchar sp8[] = {0xAA,0xD3,0xB4,0x35,0xB5,0x14,0x4,0xEE}; - uchar x[8]; - - memset(sp7,'\0',7); - - D1(sp7, sp8, x); - E1(p14, x, p16); - E1(p14+7, x, p16+8); + /* the following constant makes us compatible with other + implementations. Note that publishing this constant does not reduce the + security of the encryption mechanism */ + uchar sp8[] = {0x4b, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25}; + E1(p14, sp8, p16); + E1(p14+7, sp8, p16+8); } void E_P24(uchar *p21, uchar *c8, uchar *p24) { - E1(p21, c8, p24); - E1(p21+7, c8, p24+8); - E1(p21+14, c8, p24+16); + E1(p21, c8, p24); + E1(p21+7, c8, p24+8); + E1(p21+14, c8, p24+16); } @@ -191,6 +141,3 @@ void SMBNTencrypt(uchar *passwd, uchar *c8, uchar *p24) E_P24(p21, c8, p24); } -#else - void smbencrypt_dummy(void){} -#endif diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 047334e143..b6eabcd727 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -598,11 +598,7 @@ static void init_globals(void) #endif string_set(&Globals.szPasswdChat,"*old*password* %o\\n *new*password* %n\\n *new*password* %n\\n *changed*"); string_set(&Globals.szWorkGroup, WORKGROUP); -#ifdef SMB_PASSWD string_set(&Globals.szPasswdProgram, SMB_PASSWD); -#else - string_set(&Globals.szPasswdProgram, "/bin/passwd"); -#endif string_set(&Globals.szPrintcapname, PRINTCAP_NAME); string_set(&Globals.szLockDir, LOCKDIR); string_set(&Globals.szRootdir, "/"); diff --git a/source3/passdb/smbpass.c b/source3/passdb/smbpass.c index a31a10cef4..441ab94ffb 100644 --- a/source3/passdb/smbpass.c +++ b/source3/passdb/smbpass.c @@ -1,4 +1,3 @@ -#ifdef SMB_PASSWD /* * Unix SMB/Netbios implementation. Version 1.9. SMB parameters and setup * Copyright (C) Andrew Tridgell 1992-1997 Modified by Jeremy Allison 1995. @@ -292,8 +291,3 @@ struct smb_passwd *get_smbpwnam(char *name) pw_file_unlock(lockfd); return NULL; } -#else - void smbpass_dummy(void) -{ -} /* To avoid compiler complaints */ -#endif diff --git a/source3/smbd/ipc.c b/source3/smbd/ipc.c index 55e293d7ff..794bc7bb8e 100644 --- a/source3/smbd/ipc.c +++ b/source3/smbd/ipc.c @@ -440,7 +440,7 @@ static void PackDriverData(struct pack_desc* desc) } static int check_printq_info(struct pack_desc* desc, - int uLevel, char *id1, const char* id2) + int uLevel, char *id1, char *id2) { desc->subformat = NULL; switch( uLevel ) { diff --git a/source3/smbd/password.c b/source3/smbd/password.c index ed79d658a6..abecb46dcd 100644 --- a/source3/smbd/password.c +++ b/source3/smbd/password.c @@ -36,7 +36,6 @@ static char this_user[100]=""; static char this_salt[100]=""; static char this_crypted[100]=""; -#ifdef SMB_PASSWD /* Data to do lanman1/2 password challenge. */ static unsigned char saved_challenge[8]; static BOOL challenge_sent=False; @@ -78,7 +77,6 @@ BOOL last_challenge(char *challenge) memcpy(challenge,saved_challenge,8); return(True); } -#endif /* this holds info on user ids that are already validated for this VC */ static user_struct *validated_users = NULL; @@ -401,7 +399,7 @@ static char *PAM_password; * echo off means password. */ static int PAM_conv (int num_msg, - const struct pam_message **msg, + struct pam_message **msg, struct pam_response **resp, void *appdata_ptr) { int count = 0, replies = 0; @@ -812,7 +810,6 @@ Hence we make a direct return to avoid a second chance!!! #endif } -#ifdef SMB_PASSWD /**************************************************************************** core of smb password checking routine. ****************************************************************************/ @@ -854,7 +851,6 @@ BOOL smb_password_check(char *password, unsigned char *part_passwd, unsigned cha #endif return (memcmp(p24, password, 24) == 0); } -#endif /**************************************************************************** check if a username/password is OK @@ -864,21 +860,16 @@ BOOL password_ok(char *user,char *password, int pwlen, struct passwd *pwd) pstring pass2; int level = lp_passwordlevel(); struct passwd *pass; -#ifdef SMB_PASSWD char challenge[8]; struct smb_passwd *smb_pass; BOOL challenge_done = False; -#endif if (password) password[pwlen] = 0; -#ifdef SMB_PASSWD if (pwlen == 24) challenge_done = last_challenge(challenge); -#endif #if DEBUG_PASSWORD -#ifdef SMB_PASSWD if (challenge_done) { int i; @@ -886,10 +877,9 @@ BOOL password_ok(char *user,char *password, int pwlen, struct passwd *pwd) for( i = 0; i < 24; i++) DEBUG(100,("%0x ", (unsigned char)password[i])); DEBUG(100,("]\n")); + } else { + DEBUG(100,("checking user=[%s] pass=[%s]\n",user,password)); } - else -#endif - DEBUG(100,("checking user=[%s] pass=[%s]\n",user,password)); #endif if (!password) @@ -906,8 +896,6 @@ BOOL password_ok(char *user,char *password, int pwlen, struct passwd *pwd) else pass = Get_Pwnam(user,True); -#ifdef SMB_PASSWD - DEBUG(4,("SMB Password - pwlen = %d, challenge_done = %d\n", pwlen, challenge_done)); if((pwlen == 24) && challenge_done) @@ -964,7 +952,6 @@ BOOL password_ok(char *user,char *password, int pwlen, struct passwd *pwd) DEBUG(3,("Error smb_password_check failed\n")); } -#endif DEBUG(4,("Checking password for user %s (l=%d)\n",user,pwlen)); @@ -1587,12 +1574,12 @@ BOOL server_cryptkey(char *buf) and the remote machine name. */ { - char buf[32]; /* create name as PIDname */ - sprintf(buf,"%d", getpid()); - strncpy(&buf[strlen(buf)], remote_machine, 31 - strlen(buf)); - buf[31] = '\0'; - DEBUG(1,("negprot w/password server as %s\n",buf)); - name_mangle(buf,p,' '); + char buf2[32]; /* create name as PIDname */ + sprintf(buf2,"%d", getpid()); + strncpy(&buf2[strlen(buf2)], remote_machine, 31 - strlen(buf2)); + buf2[31] = '\0'; + DEBUG(1,("negprot w/password server as %s\n",buf2)); + name_mangle(buf2,p,' '); len += name_len(p); } diff --git a/source3/smbd/server.c b/source3/smbd/server.c index d4407269f0..8560d5239d 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -2814,19 +2814,15 @@ int reply_lanman1(char *outbuf) set_message(outbuf,13,doencrypt?8:0,True); SSVAL(outbuf,smb_vwv1,secword); -#ifdef SMB_PASSWD /* Create a token value and add it to the outgoing packet. */ if (doencrypt) generate_next_challenge(smb_buf(outbuf)); -#endif Protocol = PROTOCOL_LANMAN1; if (lp_security() == SEC_SERVER && server_cryptkey(outbuf)) { DEBUG(3,("using password server validation\n")); -#ifdef SMB_PASSWD if (doencrypt) set_challenge(smb_buf(outbuf)); -#endif } CVAL(outbuf,smb_flg) = 0x81; /* Reply, SMBlockread, SMBwritelock supported */ @@ -2865,11 +2861,9 @@ int reply_lanman2(char *outbuf) set_message(outbuf,13,doencrypt?8:0,True); SSVAL(outbuf,smb_vwv1,secword); -#ifdef SMB_PASSWD /* Create a token value and add it to the outgoing packet. */ if (doencrypt) generate_next_challenge(smb_buf(outbuf)); -#endif SIVAL(outbuf,smb_vwv6,getpid()); @@ -2877,9 +2871,7 @@ int reply_lanman2(char *outbuf) if (lp_security() == SEC_SERVER && server_cryptkey(outbuf)) { DEBUG(3,("using password server validation\n")); -#ifdef SMB_PASSWD if (doencrypt) set_challenge(smb_buf(outbuf)); -#endif } CVAL(outbuf,smb_flg) = 0x81; /* Reply, SMBlockread, SMBwritelock supported */ @@ -2949,7 +2941,6 @@ int reply_nt1(char *outbuf) #endif CVAL(outbuf,smb_vwv1) = secword; -#ifdef SMB_PASSWD /* Create a token value and add it to the outgoing packet. */ if (doencrypt) { @@ -2958,15 +2949,12 @@ int reply_nt1(char *outbuf) /* Tell the nt machine how long the challenge is. */ SSVALS(outbuf,smb_vwv16+1,challenge_len); } -#endif Protocol = PROTOCOL_NT1; if (lp_security() == SEC_SERVER && server_cryptkey(outbuf)) { DEBUG(3,("using password server validation\n")); -#ifdef SMB_PASSWD if (doencrypt) set_challenge(smb_buf(outbuf)); -#endif } SSVAL(outbuf,smb_mid,mid); /* Restore possibly corrupted mid */ diff --git a/source3/utils/make_smbcodepage.c b/source3/utils/make_smbcodepage.c index c8b4fea8bc..b4cb152334 100644 --- a/source3/utils/make_smbcodepage.c +++ b/source3/utils/make_smbcodepage.c @@ -28,7 +28,7 @@ static char *prog_name = NULL; * Print program usage and die. */ -void codepage_usage(const char *progname) +void codepage_usage(char *progname) { fprintf(stderr, "Usage is : %s [c|d] <codepage> <inputfile> <outputfile>\n", progname); @@ -162,7 +162,7 @@ void parse_error(char *buf, char *msg) * Create a compiled codepage file from a codepage definition file. */ -int do_compile(int codepage, const char *input_file, const char *output_file) +int do_compile(int codepage, char *input_file, char *output_file) { FILE *fp = NULL; uint32 size = 0; @@ -307,7 +307,7 @@ definition file. File %s has %d.\n", prog_name, input_file, num_lines); * Placeholder for now. */ -int do_decompile( int codepage, const char *input_file, const char *output_file) +int do_decompile( int codepage, char *input_file, char *output_file) { uint32 size = 0; struct stat st; diff --git a/source3/utils/smbpasswd.c b/source3/utils/smbpasswd.c index 92abce8d8f..bbcefa6b18 100644 --- a/source3/utils/smbpasswd.c +++ b/source3/utils/smbpasswd.c @@ -1,5 +1,3 @@ -#ifdef SMB_PASSWD - /* * Unix SMB/Netbios implementation. Version 1.9. smbpasswd module. Copyright * (C) Jeremy Allison 1995-1997. @@ -20,7 +18,6 @@ */ #include "includes.h" -#include "des.h" /* Static buffers we will return. */ static struct smb_passwd pw_buf; @@ -569,14 +566,3 @@ Error was %d. Password file may be corrupt ! Please examine by hand !\n", return 0; } -#else - -#include "includes.h" - -int -main(int argc, char **argv) -{ - printf("smb password encryption not selected in Makefile\n"); - return 0; -} -#endif diff --git a/source3/wsmbconf.c b/source3/wsmbconf.c index 25b3deaa29..203952c204 100644 --- a/source3/wsmbconf.c +++ b/source3/wsmbconf.c @@ -69,7 +69,7 @@ static void show_service(int snum, int allparameters) sname = SDEFAULTS; else sname = lp_servicename(snum); - printf("\n<p><table border=0>\n<tr>\n<td>\n\n"); + printf("\n<p><table border=0>\n<tr>\n<td></td><td>\n\n"); printf("<form method=POST>\n"); printf("<H3>%s</H3>\n", sname); printf("<input type=hidden name=service value=\"%s\">\n", sname); |