mirror of
https://github.com/samba-team/samba.git
synced 2025-12-02 00:23:50 +03:00
largely rewrote smbpasswd so that the code is understandable. This
should allow us to call a function in swat rather than piping to smbpasswd. while doing this I also fixed quite a few "const char *" versus "char *" issues that cropped up while using const to track down bugs in the code. This led to changes in several generic functions. The smbpasswd changes should be correct but they have not been extensively tested. At least if I have introduced bugs then we should be able to fix them more easily than before.
This commit is contained in:
@@ -258,7 +258,7 @@ BOOL matchname(char *remotehost,struct in_addr addr);
|
|||||||
void standard_sub_basic(char *str);
|
void standard_sub_basic(char *str);
|
||||||
void standard_sub(connection_struct *conn,char *str);
|
void standard_sub(connection_struct *conn,char *str);
|
||||||
BOOL same_net(struct in_addr ip1,struct in_addr ip2,struct in_addr mask);
|
BOOL same_net(struct in_addr ip1,struct in_addr ip2,struct in_addr mask);
|
||||||
struct hostent *Get_Hostbyname(char *name);
|
struct hostent *Get_Hostbyname(const char *name);
|
||||||
BOOL process_exists(int pid);
|
BOOL process_exists(int pid);
|
||||||
char *uidtoname(uid_t uid);
|
char *uidtoname(uid_t uid);
|
||||||
char *gidtoname(gid_t gid);
|
char *gidtoname(gid_t gid);
|
||||||
@@ -333,9 +333,9 @@ char *client_addr(int fd);
|
|||||||
void set_first_token(char *ptr);
|
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, int bufsize);
|
||||||
char **toktocliplist(int *ctok, char *sep);
|
char **toktocliplist(int *ctok, char *sep);
|
||||||
int StrCaseCmp(char *s, char *t);
|
int StrCaseCmp(const char *s, const char *t);
|
||||||
int StrnCaseCmp(char *s, char *t, int n);
|
int StrnCaseCmp(char *s, char *t, int n);
|
||||||
BOOL strequal(char *s1, char *s2);
|
BOOL strequal(const char *s1, const char *s2);
|
||||||
BOOL strnequal(char *s1,char *s2,int n);
|
BOOL strnequal(char *s1,char *s2,int n);
|
||||||
BOOL strcsequal(char *s1,char *s2);
|
BOOL strcsequal(char *s1,char *s2);
|
||||||
void strlower(char *s);
|
void strlower(char *s);
|
||||||
@@ -352,8 +352,8 @@ int count_chars(char *s,char c);
|
|||||||
char *safe_strcpy(char *dest,const char *src, int maxlength);
|
char *safe_strcpy(char *dest,const char *src, int maxlength);
|
||||||
char *safe_strcat(char *dest, char *src, int maxlength);
|
char *safe_strcat(char *dest, char *src, int maxlength);
|
||||||
char *StrCpy(char *dest,char *src);
|
char *StrCpy(char *dest,char *src);
|
||||||
char *StrnCpy(char *dest,char *src,int n);
|
char *StrnCpy(char *dest,const char *src,int n);
|
||||||
char *strncpyn(char *dest, char *src,int n, char c);
|
char *strncpyn(char *dest, const char *src,int n, char c);
|
||||||
int strhex_to_str(char *p, int len, const char *strhex);
|
int strhex_to_str(char *p, int len, const char *strhex);
|
||||||
BOOL in_list(char *s,char *list,BOOL casesensitive);
|
BOOL in_list(char *s,char *list,BOOL casesensitive);
|
||||||
BOOL string_init(char **dest,char *src);
|
BOOL string_init(char **dest,char *src);
|
||||||
@@ -372,7 +372,7 @@ char *unistr2_to_str(UNISTR2 *str);
|
|||||||
uint32 buffer2_to_uint32(BUFFER2 *str);
|
uint32 buffer2_to_uint32(BUFFER2 *str);
|
||||||
char *buffer2_to_str(BUFFER2 *str);
|
char *buffer2_to_str(BUFFER2 *str);
|
||||||
char *buffer2_to_multistr(BUFFER2 *str);
|
char *buffer2_to_multistr(BUFFER2 *str);
|
||||||
int struni2(uint16 *p, char *buf);
|
int struni2(uint16 *p, const char *buf);
|
||||||
char *unistr(char *buf);
|
char *unistr(char *buf);
|
||||||
int unistrcpy(char *dst, char *src);
|
int unistrcpy(char *dst, char *src);
|
||||||
|
|
||||||
@@ -435,12 +435,12 @@ BOOL cli_qfileinfo(struct cli_state *cli, int fnum,
|
|||||||
time_t *w_time, SMB_INO_T *ino);
|
time_t *w_time, SMB_INO_T *ino);
|
||||||
int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute,
|
int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute,
|
||||||
void (*fn)(file_info *, const char *));
|
void (*fn)(file_info *, const char *));
|
||||||
BOOL cli_oem_change_password(struct cli_state *cli, char *user, char *new_password,
|
BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char *new_password,
|
||||||
char *old_password);
|
const char *old_password);
|
||||||
BOOL cli_negprot(struct cli_state *cli);
|
BOOL cli_negprot(struct cli_state *cli);
|
||||||
BOOL cli_session_request(struct cli_state *cli,
|
BOOL cli_session_request(struct cli_state *cli,
|
||||||
struct nmb_name *calling, struct nmb_name *called);
|
struct nmb_name *calling, struct nmb_name *called);
|
||||||
BOOL cli_connect(struct cli_state *cli, char *host, struct in_addr *ip);
|
BOOL cli_connect(struct cli_state *cli, const char *host, struct in_addr *ip);
|
||||||
struct cli_state *cli_initialise(struct cli_state *cli);
|
struct cli_state *cli_initialise(struct cli_state *cli);
|
||||||
void cli_shutdown(struct cli_state *cli);
|
void cli_shutdown(struct cli_state *cli);
|
||||||
int cli_error(struct cli_state *cli, uint8 *eclass, uint32 *num);
|
int cli_error(struct cli_state *cli, uint8 *eclass, uint32 *num);
|
||||||
@@ -482,12 +482,12 @@ BOOL deal_with_creds(uchar sess_key[8],
|
|||||||
BOOL name_status(int fd,char *name,int name_type,BOOL recurse,
|
BOOL name_status(int fd,char *name,int name_type,BOOL recurse,
|
||||||
struct in_addr to_ip,char *master,char *rname,
|
struct in_addr to_ip,char *master,char *rname,
|
||||||
void (*fn)(struct packet_struct *));
|
void (*fn)(struct packet_struct *));
|
||||||
struct in_addr *name_query(int fd,char *name,int name_type, BOOL bcast,BOOL recurse,
|
struct in_addr *name_query(int fd,const char *name,int name_type, BOOL bcast,BOOL recurse,
|
||||||
struct in_addr to_ip, int *count, void (*fn)(struct packet_struct *));
|
struct in_addr to_ip, int *count, void (*fn)(struct packet_struct *));
|
||||||
FILE *startlmhosts(char *fname);
|
FILE *startlmhosts(char *fname);
|
||||||
BOOL getlmhostsent( FILE *fp, char *name, int *name_type, struct in_addr *ipaddr);
|
BOOL getlmhostsent( FILE *fp, char *name, int *name_type, struct in_addr *ipaddr);
|
||||||
void endlmhosts(FILE *fp);
|
void endlmhosts(FILE *fp);
|
||||||
BOOL resolve_name(char *name, struct in_addr *return_ip, int name_type);
|
BOOL resolve_name(const char *name, struct in_addr *return_ip, int name_type);
|
||||||
BOOL find_master_ip(char *group, struct in_addr *master_ip);
|
BOOL find_master_ip(char *group, struct in_addr *master_ip);
|
||||||
|
|
||||||
/*The following definitions come from libsmb/nmblib.c */
|
/*The following definitions come from libsmb/nmblib.c */
|
||||||
@@ -497,7 +497,7 @@ char *namestr(struct nmb_name *n);
|
|||||||
struct packet_struct *copy_packet(struct packet_struct *packet);
|
struct packet_struct *copy_packet(struct packet_struct *packet);
|
||||||
void free_packet(struct packet_struct *packet);
|
void free_packet(struct packet_struct *packet);
|
||||||
struct packet_struct *read_packet(int fd,enum packet_type packet_type);
|
struct packet_struct *read_packet(int fd,enum packet_type packet_type);
|
||||||
void make_nmb_name( struct nmb_name *n, char *name, int type, char *this_scope );
|
void make_nmb_name( struct nmb_name *n, const char *name, int type, const char *this_scope );
|
||||||
BOOL nmb_name_equal(struct nmb_name *n1, struct nmb_name *n2);
|
BOOL nmb_name_equal(struct nmb_name *n1, struct nmb_name *n2);
|
||||||
BOOL send_packet(struct packet_struct *p);
|
BOOL send_packet(struct packet_struct *p);
|
||||||
struct packet_struct *receive_packet(int fd,enum packet_type type,int t);
|
struct packet_struct *receive_packet(int fd,enum packet_type type,int t);
|
||||||
@@ -540,7 +540,7 @@ void nt_lm_owf_gen(char *pwd, uchar nt_p16[16], uchar p16[16]);
|
|||||||
void SMBOWFencrypt(uchar passwd[16], uchar *c8, uchar p24[24]);
|
void SMBOWFencrypt(uchar passwd[16], uchar *c8, uchar p24[24]);
|
||||||
void NTLMSSPOWFencrypt(uchar passwd[8], uchar *ntlmchalresp, uchar p24[24]);
|
void NTLMSSPOWFencrypt(uchar passwd[8], uchar *ntlmchalresp, uchar p24[24]);
|
||||||
void SMBNTencrypt(uchar *passwd, uchar *c8, uchar *p24);
|
void SMBNTencrypt(uchar *passwd, uchar *c8, uchar *p24);
|
||||||
BOOL make_oem_passwd_hash(char data[516], char *passwd, uchar old_pw_hash[16], BOOL unicode);
|
BOOL make_oem_passwd_hash(char data[516], const char *passwd, uchar old_pw_hash[16], BOOL unicode);
|
||||||
|
|
||||||
/*The following definitions come from libsmb/smberr.c */
|
/*The following definitions come from libsmb/smberr.c */
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
#define IS_BITS_SET_SOME(var,bit) (((var)&(bit))!=0)
|
#define IS_BITS_SET_SOME(var,bit) (((var)&(bit))!=0)
|
||||||
#define IS_BITS_CLR_ALL(var,bit) (((var)&(~(bit)))==0)
|
#define IS_BITS_CLR_ALL(var,bit) (((var)&(~(bit)))==0)
|
||||||
|
|
||||||
#define PTR_DIFF(p1,p2) ((ptrdiff_t)(((char *)(p1)) - (char *)(p2)))
|
#define PTR_DIFF(p1,p2) ((ptrdiff_t)(((const char *)(p1)) - (const char *)(p2)))
|
||||||
|
|
||||||
typedef int BOOL;
|
typedef int BOOL;
|
||||||
|
|
||||||
|
|||||||
@@ -2386,7 +2386,7 @@ BOOL same_net(struct in_addr ip1,struct in_addr ip2,struct in_addr mask)
|
|||||||
a wrapper for gethostbyname() that tries with all lower and all upper case
|
a wrapper for gethostbyname() that tries with all lower and all upper case
|
||||||
if the initial name fails
|
if the initial name fails
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
struct hostent *Get_Hostbyname(char *name)
|
struct hostent *Get_Hostbyname(const char *name)
|
||||||
{
|
{
|
||||||
char *name2 = strdup(name);
|
char *name2 = strdup(name);
|
||||||
struct hostent *ret;
|
struct hostent *ret;
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ char **toktocliplist(int *ctok, char *sep)
|
|||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
case insensitive string compararison
|
case insensitive string compararison
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
int StrCaseCmp(char *s, char *t)
|
int StrCaseCmp(const char *s, const char *t)
|
||||||
{
|
{
|
||||||
/* compare until we run out of string, either t or s, or find a difference */
|
/* 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
|
/* We *must* use toupper rather than tolower here due to the
|
||||||
@@ -272,7 +272,7 @@ int StrnCaseCmp(char *s, char *t, int n)
|
|||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
compare 2 strings
|
compare 2 strings
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
BOOL strequal(char *s1, char *s2)
|
BOOL strequal(const char *s1, const char *s2)
|
||||||
{
|
{
|
||||||
if (s1 == s2) return(True);
|
if (s1 == s2) return(True);
|
||||||
if (!s1 || !s2) return(False);
|
if (!s1 || !s2) return(False);
|
||||||
@@ -819,7 +819,7 @@ char *StrCpy(char *dest,char *src)
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
like strncpy but always null terminates. Make sure there is room!
|
like strncpy but always null terminates. Make sure there is room!
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
char *StrnCpy(char *dest,char *src,int n)
|
char *StrnCpy(char *dest,const char *src,int n)
|
||||||
{
|
{
|
||||||
char *d = dest;
|
char *d = dest;
|
||||||
if (!dest) return(NULL);
|
if (!dest) return(NULL);
|
||||||
@@ -837,7 +837,7 @@ char *StrnCpy(char *dest,char *src,int n)
|
|||||||
like strncpy but copies up to the character marker. always null terminates.
|
like strncpy but copies up to the character marker. always null terminates.
|
||||||
returns a pointer to the character marker in the source string (src).
|
returns a pointer to the character marker in the source string (src).
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
char *strncpyn(char *dest, char *src,int n, char c)
|
char *strncpyn(char *dest, const char *src,int n, char c)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
int str_len;
|
int str_len;
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ return number of unicode chars copied, excluding the null character.
|
|||||||
only handles ascii strings
|
only handles ascii strings
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
#define MAXUNI 1024
|
#define MAXUNI 1024
|
||||||
int struni2(uint16 *p, char *buf)
|
int struni2(uint16 *p, const char *buf)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -2087,8 +2087,8 @@ int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute,
|
|||||||
Send a SamOEMChangePassword command
|
Send a SamOEMChangePassword command
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
BOOL cli_oem_change_password(struct cli_state *cli, char *user, char *new_password,
|
BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char *new_password,
|
||||||
char *old_password)
|
const char *old_password)
|
||||||
{
|
{
|
||||||
char param[16+sizeof(fstring)];
|
char param[16+sizeof(fstring)];
|
||||||
char data[532];
|
char data[532];
|
||||||
@@ -2317,7 +2317,7 @@ retry:
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
open the client sockets
|
open the client sockets
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
BOOL cli_connect(struct cli_state *cli, char *host, struct in_addr *ip)
|
BOOL cli_connect(struct cli_state *cli, const char *host, struct in_addr *ip)
|
||||||
{
|
{
|
||||||
extern struct in_addr ipzero;
|
extern struct in_addr ipzero;
|
||||||
|
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ BOOL name_status(int fd,char *name,int name_type,BOOL recurse,
|
|||||||
returns an array of IP addresses or NULL if none
|
returns an array of IP addresses or NULL if none
|
||||||
*count will be set to the number of addresses returned
|
*count will be set to the number of addresses returned
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
struct in_addr *name_query(int fd,char *name,int name_type, BOOL bcast,BOOL recurse,
|
struct in_addr *name_query(int fd,const char *name,int name_type, BOOL bcast,BOOL recurse,
|
||||||
struct in_addr to_ip, int *count, void (*fn)(struct packet_struct *))
|
struct in_addr to_ip, int *count, void (*fn)(struct packet_struct *))
|
||||||
{
|
{
|
||||||
BOOL found=False;
|
BOOL found=False;
|
||||||
@@ -440,7 +440,7 @@ void endlmhosts(FILE *fp)
|
|||||||
/********************************************************
|
/********************************************************
|
||||||
resolve via "bcast" method
|
resolve via "bcast" method
|
||||||
*********************************************************/
|
*********************************************************/
|
||||||
static BOOL resolve_bcast(char *name, struct in_addr *return_ip, int name_type)
|
static BOOL resolve_bcast(const char *name, struct in_addr *return_ip, int name_type)
|
||||||
{
|
{
|
||||||
int sock, i;
|
int sock, i;
|
||||||
|
|
||||||
@@ -486,7 +486,7 @@ static BOOL resolve_bcast(char *name, struct in_addr *return_ip, int name_type)
|
|||||||
/********************************************************
|
/********************************************************
|
||||||
resolve via "wins" method
|
resolve via "wins" method
|
||||||
*********************************************************/
|
*********************************************************/
|
||||||
static BOOL resolve_wins(char *name, struct in_addr *return_ip, int name_type)
|
static BOOL resolve_wins(const char *name, struct in_addr *return_ip, int name_type)
|
||||||
{
|
{
|
||||||
int sock;
|
int sock;
|
||||||
struct in_addr wins_ip;
|
struct in_addr wins_ip;
|
||||||
@@ -536,7 +536,7 @@ static BOOL resolve_wins(char *name, struct in_addr *return_ip, int name_type)
|
|||||||
/********************************************************
|
/********************************************************
|
||||||
resolve via "lmhosts" method
|
resolve via "lmhosts" method
|
||||||
*********************************************************/
|
*********************************************************/
|
||||||
static BOOL resolve_lmhosts(char *name, struct in_addr *return_ip, int name_type)
|
static BOOL resolve_lmhosts(const char *name, struct in_addr *return_ip, int name_type)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* "lmhosts" means parse the local lmhosts file.
|
* "lmhosts" means parse the local lmhosts file.
|
||||||
@@ -566,7 +566,7 @@ static BOOL resolve_lmhosts(char *name, struct in_addr *return_ip, int name_type
|
|||||||
/********************************************************
|
/********************************************************
|
||||||
resolve via "hosts" method
|
resolve via "hosts" method
|
||||||
*********************************************************/
|
*********************************************************/
|
||||||
static BOOL resolve_hosts(char *name, struct in_addr *return_ip)
|
static BOOL resolve_hosts(const char *name, struct in_addr *return_ip)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* "host" means do a localhost, or dns lookup.
|
* "host" means do a localhost, or dns lookup.
|
||||||
@@ -589,7 +589,7 @@ static BOOL resolve_hosts(char *name, struct in_addr *return_ip)
|
|||||||
or NetBIOS name. This uses the name switch in the
|
or NetBIOS name. This uses the name switch in the
|
||||||
smb.conf to determine the order of name resolution.
|
smb.conf to determine the order of name resolution.
|
||||||
*********************************************************/
|
*********************************************************/
|
||||||
BOOL resolve_name(char *name, struct in_addr *return_ip, int name_type)
|
BOOL resolve_name(const char *name, struct in_addr *return_ip, int name_type)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
BOOL pure_address = True;
|
BOOL pure_address = True;
|
||||||
|
|||||||
@@ -762,7 +762,7 @@ static int build_dgram(char *buf,struct packet_struct *p)
|
|||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
build a nmb name
|
build a nmb name
|
||||||
*******************************************************************/
|
*******************************************************************/
|
||||||
void make_nmb_name( struct nmb_name *n, char *name, int type, char *this_scope )
|
void make_nmb_name( struct nmb_name *n, const char *name, int type, const char *this_scope )
|
||||||
{
|
{
|
||||||
memset( (char *)n, '\0', sizeof(struct nmb_name) );
|
memset( (char *)n, '\0', sizeof(struct nmb_name) );
|
||||||
StrnCpy( n->name, name, 15 );
|
StrnCpy( n->name, name, 15 );
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ void SMBNTencrypt(uchar *passwd, uchar *c8, uchar *p24)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL make_oem_passwd_hash(char data[516], char *passwd, uchar old_pw_hash[16], BOOL unicode)
|
BOOL make_oem_passwd_hash(char data[516], const char *passwd, uchar old_pw_hash[16], BOOL unicode)
|
||||||
{
|
{
|
||||||
int new_pw_len = strlen(passwd) * (unicode ? 2 : 1);
|
int new_pw_len = strlen(passwd) * (unicode ? 2 : 1);
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user