Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
595762d0
Commit
595762d0
authored
Aug 29, 2001
by
sasha@mysql.sashanet.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed coredump, and changed mngd->manager
parent
1c4be70c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
66 deletions
+72
-66
.bzrignore
.bzrignore
+1
-0
sql/sql_acl.cc
sql/sql_acl.cc
+6
-1
tools/Makefile.am
tools/Makefile.am
+3
-3
tools/mysqlmanager.c
tools/mysqlmanager.c
+62
-62
No files found.
.bzrignore
View file @
595762d0
...
...
@@ -399,3 +399,4 @@ tools/mysys_priv.h
vio/test-sslclient
vio/test-sslserver
vio/viotest-ssl
tools/mysqlmanager
sql/sql_acl.cc
View file @
595762d0
...
...
@@ -61,7 +61,9 @@ class ACL_USER :public ACL_ACCESS
uint
hostname_length
;
char
*
user
,
*
password
;
ulong
salt
[
2
];
#ifdef HAVE_OPENSSL
char
*
ssl_type
,
*
ssl_cipher
,
*
ssl_issuer
,
*
ssl_subject
;
#endif
};
class
ACL_DB
:
public
ACL_ACCESS
...
...
@@ -200,10 +202,12 @@ int acl_init(bool dont_read_acl_tables)
update_hostname
(
&
user
.
host
,
get_field
(
&
mem
,
table
,
0
));
user
.
user
=
get_field
(
&
mem
,
table
,
1
);
user
.
password
=
get_field
(
&
mem
,
table
,
2
);
#ifdef HAVE_OPENSSL
user
.
ssl_type
=
get_field
(
&
mem
,
table
,
17
);
user
.
ssl_cipher
=
get_field
(
&
mem
,
table
,
18
);
user
.
ssl_issuer
=
get_field
(
&
mem
,
table
,
19
);
user
.
ssl_subject
=
get_field
(
&
mem
,
table
,
20
);
#endif
if
(
user
.
password
&&
(
length
=
(
uint
)
strlen
(
user
.
password
))
==
8
&&
protocol_version
==
PROTOCOL_VERSION
)
{
...
...
@@ -2416,6 +2420,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user)
global
.
append
(
passd_buff
);
global
.
append
(
'\''
);
}
#ifdef HAVE_OPENSSL
/* SSL grant stuff */
DBUG_PRINT
(
"info"
,(
"acl_user->ssl_type=%s"
,
acl_user
->
ssl_type
));
DBUG_PRINT
(
"info"
,(
"acl_user->ssl_cipher=%s"
,
acl_user
->
ssl_cipher
));
...
...
@@ -2439,7 +2444,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user)
}
}
}
#endif
if
(
want_access
&
GRANT_ACL
)
global
.
append
(
" WITH GRANT OPTION"
,
18
);
thd
->
packet
.
length
(
0
);
...
...
tools/Makefile.am
View file @
595762d0
...
...
@@ -3,9 +3,9 @@ INCLUDES = -I$(srcdir)/../include $(openssl_includes) \
-I
..
LIBS
=
@TOOLS_LIBS@
LDADD
=
@CLIENT_EXTRA_LDFLAGS@ ../libmysql_r/libmysqlclient_r.la
bin_PROGRAMS
=
mysqlm
ngd
mysqlm
ngd_SOURCES
=
mysqlmngd.c my_vsnprintf
.c
#mysqltest
_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES)
bin_PROGRAMS
=
mysqlm
anager
mysqlm
anager_SOURCES
=
mysqlmanager
.c
mysqlmanager
_DEPENDENCIES
=
$(LIBRARIES)
$(pkglib_LTLIBRARIES)
DEFS
=
-DUNDEF_THREADS_HACK
# Don't update the files from bitkeeper
...
...
tools/mysqlm
ngd
.c
→
tools/mysqlm
anager
.c
View file @
595762d0
...
...
@@ -57,7 +57,7 @@
#endif
#ifndef MNGD_LOG_FILE
#define MNGD_LOG_FILE "/var/log/mysqlm
ngd
.log"
#define MNGD_LOG_FILE "/var/log/mysqlm
anager
.log"
#endif
#ifndef MNGD_BACK_LOG
...
...
@@ -68,22 +68,22 @@
#define MAX_USER_NAME 16
#endif
/* Variable naming convention - if starts with m
ngd
_, either is set
/* Variable naming convention - if starts with m
anager
_, either is set
directly by the user, or used closely in ocnjunction with a variable
set by the user
*/
uint
m
ngd
_port
=
MNGD_PORT
;
uint
m
anager
_port
=
MNGD_PORT
;
FILE
*
errfp
;
const
char
*
m
ngd
_log_file
=
MNGD_LOG_FILE
;
const
char
*
m
anager
_log_file
=
MNGD_LOG_FILE
;
pthread_mutex_t
lock_log
,
lock_shutdown
;
int
m
ngd
_sock
=
-
1
;
struct
sockaddr_in
m
ngd
_addr
;
ulong
m
ngd
_bind_addr
=
INADDR_ANY
;
int
m
ngd
_back_log
=
MNGD_BACK_LOG
;
int
m
anager
_sock
=
-
1
;
struct
sockaddr_in
m
anager
_addr
;
ulong
m
anager
_bind_addr
=
INADDR_ANY
;
int
m
anager
_back_log
=
MNGD_BACK_LOG
;
int
in_shutdown
=
0
,
shutdown_requested
=
0
;
const
char
*
m
ngd
_greeting
=
MNGD_GREETING
;
uint
m
ngd
_max_cmd_len
=
MNGD_MAX_CMD_LEN
;
const
char
*
m
anager
_greeting
=
MNGD_GREETING
;
uint
m
anager
_max_cmd_len
=
MNGD_MAX_CMD_LEN
;
/* messages */
...
...
@@ -103,7 +103,7 @@ uint mngd_max_cmd_len = MNGD_MAX_CMD_LEN;
#define PRIV_SHUTDOWN 1
struct
m
ngd
_thd
struct
m
anager
_thd
{
Vio
*
vio
;
char
user
[
MAX_USER_NAME
];
...
...
@@ -112,25 +112,25 @@ struct mngd_thd
int
fatal
,
finished
;
};
struct
m
ngd_thd
*
mngd
_thd_new
(
Vio
*
vio
);
void
m
ngd_thd_free
(
struct
mngd
_thd
*
thd
);
struct
m
anager_thd
*
manager
_thd_new
(
Vio
*
vio
);
void
m
anager_thd_free
(
struct
manager
_thd
*
thd
);
typedef
int
(
*
m
ngd_cmd_handler
)(
struct
mngd
_thd
*
,
char
*
,
char
*
);
typedef
int
(
*
m
anager_cmd_handler
)(
struct
manager
_thd
*
,
char
*
,
char
*
);
struct
m
ngd
_cmd
struct
m
anager
_cmd
{
const
char
*
name
;
const
char
*
help
;
m
ngd
_cmd_handler
handler_func
;
m
anager
_cmd_handler
handler_func
;
int
len
;
};
#define HANDLE_DECL(com) static int handle_ ## com (struct m
ngd
_thd* thd,\
#define HANDLE_DECL(com) static int handle_ ## com (struct m
anager
_thd* thd,\
char* args_start,char* args_end)
#define HANDLE_NOARG_DECL(com) static int handle_ ## com \
(struct m
ngd
_thd* thd, char* __attribute__((unused)) args_start,\
(struct m
anager
_thd* thd, char* __attribute__((unused)) args_start,\
char* __attribute__((unused)) args_end)
...
...
@@ -139,7 +139,7 @@ HANDLE_NOARG_DECL(quit);
HANDLE_NOARG_DECL
(
help
);
HANDLE_NOARG_DECL
(
shutdown
);
struct
m
ngd
_cmd
commands
[]
=
struct
m
anager
_cmd
commands
[]
=
{
{
"ping"
,
"Check if this server is alive"
,
handle_ping
,
4
},
{
"quit"
,
"Finish session"
,
handle_quit
,
4
},
...
...
@@ -165,22 +165,22 @@ struct option long_options[] =
static
void
die
(
const
char
*
fmt
,...);
static
void
print_time
(
FILE
*
fp
);
static
void
clean_up
();
static
struct
m
ngd
_cmd
*
lookup_cmd
(
char
*
s
,
int
len
);
static
struct
m
anager
_cmd
*
lookup_cmd
(
char
*
s
,
int
len
);
static
void
client_msg
(
Vio
*
vio
,
int
err_code
,
const
char
*
fmt
,...);
static
void
client_msg_pre
(
Vio
*
vio
,
int
err_code
,
const
char
*
fmt
,...);
static
void
client_msg_raw
(
Vio
*
vio
,
int
err_code
,
int
pre
,
const
char
*
fmt
,
va_list
args
);
static
int
authenticate
(
struct
m
ngd
_thd
*
thd
);
static
char
*
read_line
(
struct
m
ngd
_thd
*
thd
);
/* returns pointer to end of
static
int
authenticate
(
struct
m
anager
_thd
*
thd
);
static
char
*
read_line
(
struct
m
anager
_thd
*
thd
);
/* returns pointer to end of
line
*/
static
pthread_handler_decl
(
process_connection
,
arg
);
static
int
exec_line
(
struct
m
ngd
_thd
*
thd
,
char
*
buf
,
char
*
buf_end
);
static
int
exec_line
(
struct
m
anager
_thd
*
thd
,
char
*
buf
,
char
*
buf_end
);
static
int
exec_line
(
struct
m
ngd
_thd
*
thd
,
char
*
buf
,
char
*
buf_end
)
static
int
exec_line
(
struct
m
anager
_thd
*
thd
,
char
*
buf
,
char
*
buf_end
)
{
char
*
p
=
buf
;
struct
m
ngd
_cmd
*
cmd
;
struct
m
anager
_cmd
*
cmd
;
for
(;
p
<
buf_end
&&
!
isspace
(
*
p
);
p
++
)
*
p
=
tolower
(
*
p
);
if
(
!
(
cmd
=
lookup_cmd
(
buf
,(
int
)(
p
-
buf
))))
...
...
@@ -193,9 +193,9 @@ static int exec_line(struct mngd_thd* thd,char* buf,char* buf_end)
return
cmd
->
handler_func
(
thd
,
p
,
buf_end
);
}
static
struct
m
ngd
_cmd
*
lookup_cmd
(
char
*
s
,
int
len
)
static
struct
m
anager
_cmd
*
lookup_cmd
(
char
*
s
,
int
len
)
{
struct
m
ngd
_cmd
*
cmd
=
commands
;
struct
m
anager
_cmd
*
cmd
=
commands
;
for
(;
cmd
->
name
;
cmd
++
)
{
if
(
cmd
->
len
==
len
&&
!
memcmp
(
cmd
->
name
,
s
,
len
))
...
...
@@ -219,7 +219,7 @@ HANDLE_NOARG_DECL(quit)
HANDLE_NOARG_DECL
(
help
)
{
struct
m
ngd
_cmd
*
cmd
=
commands
;
struct
m
anager
_cmd
*
cmd
=
commands
;
Vio
*
vio
=
thd
->
vio
;
client_msg_pre
(
vio
,
MSG_INFO
,
"Available commands:"
);
for
(;
cmd
->
name
;
cmd
++
)
...
...
@@ -238,10 +238,10 @@ HANDLE_NOARG_DECL(shutdown)
return
0
;
}
static
int
authenticate
(
struct
m
ngd
_thd
*
thd
)
static
int
authenticate
(
struct
m
anager
_thd
*
thd
)
{
char
*
buf_end
;
client_msg
(
thd
->
vio
,
MSG_INFO
,
m
ngd
_greeting
);
client_msg
(
thd
->
vio
,
MSG_INFO
,
m
anager
_greeting
);
if
(
!
(
buf_end
=
read_line
(
thd
)))
return
-
1
;
client_msg
(
thd
->
vio
,
MSG_OK
,
"OK"
);
...
...
@@ -327,7 +327,7 @@ LOG_MSG_FUNC(debug,DEBUG)
static
pthread_handler_decl
(
process_connection
,
arg
)
{
struct
m
ngd_thd
*
thd
=
(
struct
mngd
_thd
*
)
arg
;
struct
m
anager_thd
*
thd
=
(
struct
manager
_thd
*
)
arg
;
my_thread_init
();
pthread_detach_this_thread
();
for
(;
!
thd
->
finished
;)
...
...
@@ -340,7 +340,7 @@ static pthread_handler_decl(process_connection,arg)
break
;
}
}
m
ngd
_thd_free
(
thd
);
m
anager
_thd_free
(
thd
);
pthread_exit
(
0
);
}
...
...
@@ -377,10 +377,10 @@ static void client_msg_pre(Vio* vio, int err_code, const char* fmt, ...)
client_msg_raw
(
vio
,
err_code
,
1
,
fmt
,
args
);
}
static
char
*
read_line
(
struct
m
ngd
_thd
*
thd
)
static
char
*
read_line
(
struct
m
anager
_thd
*
thd
)
{
char
*
p
=
thd
->
cmd_buf
;
char
*
buf_end
=
thd
->
cmd_buf
+
m
ngd
_max_cmd_len
;
char
*
buf_end
=
thd
->
cmd_buf
+
m
anager
_max_cmd_len
;
int
escaped
=
0
;
for
(;
p
<
buf_end
;)
{
...
...
@@ -422,13 +422,13 @@ static char* read_line(struct mngd_thd* thd)
return
0
;
}
struct
m
ngd_thd
*
mngd
_thd_new
(
Vio
*
vio
)
struct
m
anager_thd
*
manager
_thd_new
(
Vio
*
vio
)
{
struct
m
ngd
_thd
*
tmp
;
if
(
!
(
tmp
=
(
struct
m
ngd_thd
*
)
my_malloc
(
sizeof
(
*
tmp
)
+
mngd
_max_cmd_len
,
struct
m
anager
_thd
*
tmp
;
if
(
!
(
tmp
=
(
struct
m
anager_thd
*
)
my_malloc
(
sizeof
(
*
tmp
)
+
manager
_max_cmd_len
,
MYF
(
0
))))
{
log_err
(
"Out of memory in m
ngd
_thd_new"
);
log_err
(
"Out of memory in m
anager
_thd_new"
);
return
0
;
}
tmp
->
vio
=
vio
;
...
...
@@ -439,7 +439,7 @@ struct mngd_thd* mngd_thd_new(Vio* vio)
return
tmp
;
}
void
m
ngd_thd_free
(
struct
mngd
_thd
*
thd
)
void
m
anager_thd_free
(
struct
manager
_thd
*
thd
)
{
if
(
thd
->
vio
)
vio_close
(
thd
->
vio
);
...
...
@@ -457,8 +457,8 @@ static void clean_up()
in_shutdown
=
1
;
pthread_mutex_unlock
(
&
lock_shutdown
);
log_info
(
"Shutdown started"
);
if
(
m
ngd
_sock
)
close
(
m
ngd
_sock
);
if
(
m
anager
_sock
)
close
(
m
anager
_sock
);
log_info
(
"Ended"
);
if
(
errfp
!=
stderr
)
fclose
(
errfp
);
...
...
@@ -505,21 +505,21 @@ int parse_args(int argc, char **argv)
DBUG_PUSH
(
optarg
?
optarg
:
"d:t:O,/tmp/mysqlmgrd.trace"
);
break
;
case
'P'
:
m
ngd
_port
=
atoi
(
optarg
);
m
anager
_port
=
atoi
(
optarg
);
break
;
case
'm'
:
m
ngd
_max_cmd_len
=
atoi
(
optarg
);
m
anager
_max_cmd_len
=
atoi
(
optarg
);
break
;
case
'g'
:
m
ngd
_greeting
=
optarg
;
m
anager
_greeting
=
optarg
;
case
'b'
:
m
ngd
_bind_addr
=
inet_addr
(
optarg
);
m
anager
_bind_addr
=
inet_addr
(
optarg
);
break
;
case
'B'
:
m
ngd
_back_log
=
atoi
(
optarg
);
m
anager
_back_log
=
atoi
(
optarg
);
break
;
case
'l'
:
m
ngd
_log_file
=
optarg
;
m
anager
_log_file
=
optarg
;
break
;
case
'V'
:
print_version
();
...
...
@@ -539,16 +539,16 @@ int init_server()
{
int
arg
=
1
;
log_info
(
"Started"
);
if
((
m
ngd
_sock
=
socket
(
PF_INET
,
SOCK_STREAM
,
0
))
<
0
)
if
((
m
anager
_sock
=
socket
(
PF_INET
,
SOCK_STREAM
,
0
))
<
0
)
die
(
"Could not create socket"
);
bzero
((
char
*
)
&
m
ngd_addr
,
sizeof
(
mngd
_addr
));
m
ngd
_addr
.
sin_family
=
AF_INET
;
m
ngd_addr
.
sin_addr
.
s_addr
=
mngd
_bind_addr
;
m
ngd_addr
.
sin_port
=
htons
(
mngd
_port
);
setsockopt
(
m
ngd
_sock
,
SOL_SOCKET
,
SO_REUSEADDR
,(
char
*
)
&
arg
,
sizeof
(
arg
));
if
(
bind
(
m
ngd_sock
,(
struct
sockaddr
*
)
&
mngd_addr
,
sizeof
(
mngd
_addr
))
<
0
)
bzero
((
char
*
)
&
m
anager_addr
,
sizeof
(
manager
_addr
));
m
anager
_addr
.
sin_family
=
AF_INET
;
m
anager_addr
.
sin_addr
.
s_addr
=
manager
_bind_addr
;
m
anager_addr
.
sin_port
=
htons
(
manager
_port
);
setsockopt
(
m
anager
_sock
,
SOL_SOCKET
,
SO_REUSEADDR
,(
char
*
)
&
arg
,
sizeof
(
arg
));
if
(
bind
(
m
anager_sock
,(
struct
sockaddr
*
)
&
manager_addr
,
sizeof
(
manager
_addr
))
<
0
)
die
(
"Could not bind"
);
if
(
listen
(
m
ngd_sock
,
mngd
_back_log
)
<
0
)
if
(
listen
(
m
anager_sock
,
manager
_back_log
)
<
0
)
die
(
"Could not listen"
);
return
0
;
...
...
@@ -557,14 +557,14 @@ int init_server()
int
run_server_loop
()
{
pthread_t
th
;
struct
m
ngd
_thd
*
thd
;
struct
m
anager
_thd
*
thd
;
int
client_sock
,
len
;
Vio
*
vio
;
for
(;
!
shutdown_requested
;)
{
len
=
sizeof
(
struct
sockaddr_in
);
if
((
client_sock
=
accept
(
m
ngd_sock
,(
struct
sockaddr
*
)
&
mngd
_addr
,
&
len
))
<
0
)
if
((
client_sock
=
accept
(
m
anager_sock
,(
struct
sockaddr
*
)
&
manager
_addr
,
&
len
))
<
0
)
{
if
(
shutdown_requested
)
break
;
...
...
@@ -583,7 +583,7 @@ int run_server_loop()
close
(
client_sock
);
continue
;
}
if
(
!
(
thd
=
m
ngd
_thd_new
(
vio
)))
if
(
!
(
thd
=
m
anager
_thd_new
(
vio
)))
{
log_err
(
"Could not create thread object"
);
vio_close
(
vio
);
...
...
@@ -593,7 +593,7 @@ int run_server_loop()
if
(
authenticate
(
thd
))
{
client_msg
(
vio
,
MSG_ACCESS
,
"Access denied"
);
m
ngd
_thd_free
(
thd
);
m
anager
_thd_free
(
thd
);
continue
;
}
if
(
shutdown_requested
)
...
...
@@ -602,7 +602,7 @@ int run_server_loop()
{
client_msg
(
vio
,
MSG_INTERNAL_ERR
,
"Could not create thread, errno=%d"
,
errno
);
m
ngd
_thd_free
(
thd
);
m
anager
_thd_free
(
thd
);
continue
;
}
}
...
...
@@ -612,8 +612,8 @@ int run_server_loop()
FILE
*
open_log_stream
()
{
FILE
*
fp
;
if
(
!
(
fp
=
fopen
(
m
ngd
_log_file
,
"a"
)))
die
(
"Could not open log file '%s'"
,
m
ngd
_log_file
);
if
(
!
(
fp
=
fopen
(
m
anager
_log_file
,
"a"
)))
die
(
"Could not open log file '%s'"
,
m
anager
_log_file
);
return
fp
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment