LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-17-2018, 12:49 AM   #1
Herrick19
LQ Newbie
 
Registered: Feb 2018
Posts: 6

Rep: Reputation: Disabled
Question Help with STDIN and multiple source of input


Hi,

I'm confused about exactly what is the problem I'm facing so I'll explain what I am trying to achieve hoping someone can help me out.

MySQL has a command line interface you can call like this (let's say my user is "user" and my password is "1234" and my database is db)

mysql -u user -p1234 db < a.sql

Specifying the password on the command line is bad so you can call the same command this way and you will be prompted for it interactively
mysql -u user -p db < a.sql

It works well, no problem with this...

Now, I'm trying to do the same thing in PHP using proc_open(http://us3.php.net/manual/en/function.proc-open.php)


What I don't get is that is there 2 stdin ? one for the file and one for the interractive prompt ?

Doing this works like a charm (sending the .sql file over stdin):
~~~~~~~~~~~~~~~~
$hProcess = proc_open(
"mysql -u user -p1234 db",
array (
0 => array("pipe", "r"), // stdin
1 => array("pipe", "w"), // stdout
2 => array("pipe", "w") // stderr
),
$a_Pipes
);

if (is_resource($hProcess)) {
//sending sql content on on STDIN
fwrite($a_Pipes[0], "file_get_contents('a.sql')");
fclose($a_Pipes[0]);

fclose($a_Pipes[1]);
fclose($a_Pipes[2]);

$iReturn = proc_close($hProcess);
~~~~~~~~~~~~~~
Doing this works like a charm (sending the password over stdin but sending the query on the command line):
~~~~~~~~~~~~~~
$hProcess = proc_open(
"mysql -u user -p db -e "select 'foo' from DUAL"",
array (
0 => array("pipe", "r"), // stdin
1 => array("pipe", "w"), // stdout
2 => array("pipe", "w") // stderr
),
$a_Pipes
);

if (is_resource($hProcess)) {
//sending password on STDIN
fwrite($a_Pipes[0], "1234\n");
fclose($a_Pipes[0]);

fclose($a_Pipes[1]);
fclose($a_Pipes[2]);

$iReturn = proc_close($hProcess);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

But how can I send both the password AND the sql content ?

I tried to write both the password and the sql file on stdin -> didn't work
I tried to send just the password on stdin and send the sql file using "<" in the command didn't work
I tried to pipe a cat on the sql file to mysql while sending the password over stdin and it didn't work...
I tried to create another piped stream #3 to write to it, didn't work...

How is mysql able to get valud from both interractive AND stdin ?

I've read posts about writing password to environment variables or text file, but I'm looking for a safer approach...

Any help would be appreciated.

Thanks in advance

Last edited by Herrick19; 02-17-2018 at 12:50 AM.
 
Old 02-17-2018, 02:27 AM   #2
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196
Welcome to LQ!

Please place your code snippets inside [CODE]...[/CODE] tags for better readability. You may type those yourself or click the "#" button in the edit controls.

I have never used PHP's proc_open(...), but from your description and a quick look at the manual page linked, I think the way to do that would be to use a "file" element in the descriptorspec array.

Quote:
Originally Posted by Herrick19 View Post
mysql -u user -p db < a.sql

It works well, no problem with this...

Now, I'm trying to do the same thing in PHP using proc_open(http://us3.php.net/manual/en/function.proc-open.php)
So I would think that the same thing would be something like this (not tested):

Code:
$hProcess = proc_open(
"mysql -u user -p db -e "select 'foo' from DUAL"",
array (
0 => array("pipe", "r"), // stdin
1 => array("pipe", "w"), // stdout
2 => array("pipe", "w") // stderr
3 => array("file", "/path/to/sql/file", "r") // file
),
$a_Pipes
);

if (is_resource($hProcess)) {
//sending password on STDIN
fwrite($a_Pipes[0], "1234\n");
fclose($a_Pipes[0]);
...
}
That may work the same way, with the mysql client prompting for, and receiving the password from STDIN (file descriptor 0), then reading from the file (file descriptor 3).

If it is not that simple, look through the manual or for examples of using the file argument to the descriptor array. You may have to write to the file pipe, but as you can give it a filespec and open for reading it seems to me that it should be ready to go as is.

Good luck!

Last edited by astrogeek; 02-17-2018 at 02:36 AM. Reason: typo, added comment
 
1 members found this post helpful.
Old 02-17-2018, 02:35 AM   #3
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,869
Blog Entries: 1

Rep: Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870
Tell no-one, but PHP does have built-in Mysql support, there is no point in calling 'mysql(1)' as external program from PHP.
 
Old 02-17-2018, 02:42 AM   #4
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196
Quote:
Originally Posted by NevemTeve View Post
Tell no-one, but PHP does have built-in Mysql support, there is no point in calling 'mysql(1)' as external program from PHP.
I had the same thought, but as the OP seems to want to be prompted for password and to read from an existing SQL file which may not be easily parsed into single queries, proc_open may be useful.

Perhaps the OP could tell us more about what their actual goals and constraints are as well.
 
1 members found this post helpful.
Old 02-17-2018, 03:04 AM   #5
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,869
Blog Entries: 1

Rep: Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870
Well, here is a question worth examining:
How does mysql(1) know that it can ask for a password from /dev/tty (confidentally), even if its stdin is redirected to a file? I cannot strace/truss it right now; my guess is that it checks isatty(0)||isatty(1)||isatty(2), or it simply tries to open /dev/tty and if it fails, uses stdin instead.
 
2 members found this post helpful.
Old 02-18-2018, 04:29 PM   #6
Herrick19
LQ Newbie
 
Registered: Feb 2018
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by astrogeek View Post
So I would think that the same thing would be something like this (not tested):

Code:
$hProcess = proc_open(
"mysql -u user -p db -e "select 'foo' from DUAL"",
array (
0 => array("pipe", "r"), // stdin
1 => array("pipe", "w"), // stdout
2 => array("pipe", "w") // stderr
3 => array("file", "/path/to/sql/file", "r") // file
),
$a_Pipes
);

if (is_resource($hProcess)) {
//sending password on STDIN
fwrite($a_Pipes[0], "1234\n");
fclose($a_Pipes[0]);
...
}
That may work the same way, with the mysql client prompting for, and receiving the password from STDIN (file descriptor 0), then reading from the file (file descriptor 3).
Hi Thanks for the info. I tried to do it, it "works" meaning there is no error, but the MySQL process "hangs" waiting for input like if I was in regular cli mode.

So I'm not sure how a process on linux "knows" if it needs to read from #0 or #3, but here even if #3 is a handle to a sql file, MySQL doesnt try to read from it
 
Old 02-18-2018, 04:43 PM   #7
Herrick19
LQ Newbie
 
Registered: Feb 2018
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by NevemTeve View Post
Well, here is a question worth examining:
How does mysql(1) know that it can ask for a password from /dev/tty (confidentally), even if its stdin is redirected to a file? I cannot strace/truss it right now; my guess is that it checks isatty(0)||isatty(1)||isatty(2), or it simply tries to open /dev/tty and if it fails, uses stdin instead.
With your comment, I tried this:
PHP Code:
$hProcess proc_open(
                    
"mysql -u user -p db < $sTempFile",
                    array (
                        
=> array("pipe""r"), // stdin
                        
=> array("pipe""w"), // stdout
                        
=> array("pipe""w"), // stderr
                        
=> array("file""/dev/tty""r+"// stderr
                    
),
                    
$a_Pipes
                    
); 
I was thinking I could send the password on descriptor 3 but I'm getting an error proc_open(/dev/tty): failed to open stream: No such device or address




Quote:
Originally Posted by NevemTeve View Post
I cannot strace/truss it right now;
I tried to run strace, I'm not sure what I should be looking for in there. Do you have an a hint in the following trace ?

Code:
execve("/usr/bin/mysql", ["mysql", "-u", "user", "-p", "db"], [/* 25 vars */]) = 0
brk(NULL)                               = 0xf10000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fbb17a28000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=49803, ...}) = 0
mmap(NULL, 49803, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fbb17a1b000
close(3)                                = 0
open("/lib64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\240l\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=143944, ...}) = 0
mmap(NULL, 2208864, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fbb175ee000
mprotect(0x7fbb17605000, 2093056, PROT_NONE) = 0
mmap(0x7fbb17804000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16000) = 0x7fbb17804000
mmap(0x7fbb17806000, 13408, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fbb17806000
close(3)                                = 0
open("/lib64/librt.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\"\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=44448, ...}) = 0
mmap(NULL, 2128952, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fbb173e6000
mprotect(0x7fbb173ed000, 2093056, PROT_NONE) = 0
mmap(0x7fbb175ec000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6000) = 0x7fbb175ec000
close(3)                                = 0
open("/lib64/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0`\16\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=19776, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fbb17a1a000
mmap(NULL, 2109744, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fbb171e2000
mprotect(0x7fbb171e4000, 2097152, PROT_NONE) = 0
mmap(0x7fbb173e4000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7fbb173e4000
close(3)                                = 0
open("/lib64/libncurses.so.5", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0Pm\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=163680, ...}) = 0
mmap(NULL, 2254920, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fbb16fbb000
mprotect(0x7fbb16fe1000, 2093056, PROT_NONE) = 0
mmap(0x7fbb171e0000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x25000) = 0x7fbb171e0000
close(3)                                = 0
open("/lib64/libtinfo.so.5", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@\316\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=174520, ...}) = 0
mmap(NULL, 2268928, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fbb16d91000
mprotect(0x7fbb16db6000, 2097152, PROT_NONE) = 0
mmap(0x7fbb16fb6000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x25000) = 0x7fbb16fb6000
close(3)                                = 0
open("/lib64/libstdc++.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\20\265\5\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=999944, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fbb17a19000
mmap(NULL, 3179552, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fbb16a88000
mprotect(0x7fbb16b71000, 2097152, PROT_NONE) = 0
mmap(0x7fbb16d71000, 45056, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xe9000) = 0x7fbb16d71000
mmap(0x7fbb16d7c000, 82976, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fbb16d7c000
close(3)                                = 0
open("/lib64/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0`T\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1141928, ...}) = 0
mmap(NULL, 3150152, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fbb16786000
mprotect(0x7fbb16886000, 2097152, PROT_NONE) = 0
mmap(0x7fbb16a86000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x100000) = 0x7fbb16a86000
close(3)                                = 0
open("/lib64/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360*\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=88720, ...}) = 0
mmap(NULL, 2184192, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fbb16570000
mprotect(0x7fbb16585000, 2093056, PROT_NONE) = 0
mmap(0x7fbb16784000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x14000) = 0x7fbb16784000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@\34\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=2118128, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fbb17a18000
mmap(NULL, 3932672, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fbb161af000
mprotect(0x7fbb16365000, 2097152, PROT_NONE) = 0
mmap(0x7fbb16565000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b6000) = 0x7fbb16565000
mmap(0x7fbb1656b000, 16896, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fbb1656b000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fbb17a17000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fbb17a15000
arch_prctl(ARCH_SET_FS, 0x7fbb17a15740) = 0
mprotect(0x7fbb16565000, 16384, PROT_READ) = 0
mprotect(0x7fbb16784000, 4096, PROT_READ) = 0
mprotect(0x7fbb16a86000, 4096, PROT_READ) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fbb17a14000
mprotect(0x7fbb16d71000, 36864, PROT_READ) = 0
mprotect(0x7fbb16fb6000, 16384, PROT_READ) = 0
mprotect(0x7fbb173e4000, 4096, PROT_READ) = 0
mprotect(0x7fbb171e0000, 4096, PROT_READ) = 0
mprotect(0x7fbb17804000, 4096, PROT_READ) = 0
mprotect(0x7fbb175ec000, 4096, PROT_READ) = 0
mprotect(0x9c1000, 32768, PROT_READ)    = 0
mprotect(0x7fbb17a29000, 4096, PROT_READ) = 0
munmap(0x7fbb17a1b000, 49803)           = 0
set_tid_address(0x7fbb17a15a10)         = 5586
set_robust_list(0x7fbb17a15a20, 24)     = 0
rt_sigaction(SIGRTMIN, {0x7fbb175f4780, [], SA_RESTORER|SA_SIGINFO, 0x7fbb175fd370}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {0x7fbb175f4810, [], SA_RESTORER|SA_RESTART|SA_SIGINFO, 0x7fbb175fd370}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
brk(NULL)                               = 0xf10000
brk(0xf31000)                           = 0xf31000
brk(NULL)                               = 0xf31000
ioctl(0, TCGETS, 0x7ffe87d68380)        = -1 ENOTTY (Inappropriate ioctl for device)
dup(1)                                  = 3
close(3)                                = 0
stat("/etc/my.cnf", {st_mode=S_IFREG|0644, st_size=1221, ...}) = 0
open("/etc/my.cnf", O_RDONLY)           = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=1221, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fbb17a27000
read(3, "# For advice on how to change se"..., 4096) = 1221
read(3, "", 4096)                       = 0
close(3)                                = 0
munmap(0x7fbb17a27000, 4096)            = 0
stat("/etc/mysql/my.cnf", 0x7ffe87d636a0) = -1 ENOENT (No such file or directory)
stat("/usr/etc/my.cnf", 0x7ffe87d636a0) = -1 ENOENT (No such file or directory)
stat("/root/.my.cnf", 0x7ffe87d636a0)   = -1 ENOENT (No such file or directory)
stat("/root/.mylogin.cnf", 0x7ffe87d636a0) = -1 ENOENT (No such file or directory)
open("/dev/tty", O_RDWR|O_CREAT|O_TRUNC|O_CLOEXEC, 0666) = 3
ioctl(3, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(3, SNDCTL_TMR_CONTINUE or TCSETSF, {B38400 opost -isig icanon -echo ...}) = 0
fstat(3, {st_mode=S_IFCHR|0666, st_rdev=makedev(5, 0), ...}) = 0
ioctl(3, TCGETS, {B38400 opost -isig icanon -echo ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fbb17a27000
write(3, "Enter password: ", 16Enter password: )        = 16
read(3, "1234\n", 4096)              = 8
write(3, "\n", 1
)                       = 1
ioctl(3, SNDCTL_TMR_CONTINUE or TCSETSF, {B38400 opost isig icanon echo ...}) = 0
close(3)                                = 0
munmap(0x7fbb17a27000, 4096)            = 0
fstat(0, {st_mode=S_IFREG|0644, st_size=1318404, ...}) = 0
socket(AF_LOCAL, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
connect(3, {sa_family=AF_LOCAL, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
close(3)                                = 0
socket(AF_LOCAL, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
connect(3, {sa_family=AF_LOCAL, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
close(3)                                = 0
open("/etc/nsswitch.conf", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=1728, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fbb17a27000
read(3, "#\n# /etc/nsswitch.conf\n#\n# An ex"..., 4096) = 1728
read(3, "", 4096)                       = 0
close(3)                                = 0
munmap(0x7fbb17a27000, 4096)            = 0
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=49803, ...}) = 0
mmap(NULL, 49803, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fbb17a1b000
close(3)                                = 0
open("/lib64/libnss_files.so.2", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\320!\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=62184, ...}) = 0
mmap(NULL, 2173048, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fbb15f9c000
mprotect(0x7fbb15fa8000, 2093056, PROT_NONE) = 0
mmap(0x7fbb161a7000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xb000) = 0x7fbb161a7000
mmap(0x7fbb161a9000, 22648, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fbb161a9000
close(3)                                = 0
mprotect(0x7fbb161a7000, 4096, PROT_READ) = 0
munmap(0x7fbb17a1b000, 49803)           = 0
open("/etc/services", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=670293, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fbb17a27000
read(3, "# /etc/services:\n# $Id: services"..., 4096) = 4096
read(3, " 74/udp                         "..., 4096) = 4096
read(3, "     # Quick Mail Transfer Proto"..., 4096) = 4096
read(3, "    636/udp                     "..., 4096) = 4096
read(3, "          # Microsoft-SQL-Monito"..., 4096) = 4096
read(3, "                       # discp s"..., 4096) = 4096
close(3)                                = 0
munmap(0x7fbb17a27000, 4096)            = 0
rt_sigaction(SIGPIPE, {SIG_IGN, [PIPE], SA_RESTORER|SA_RESTART, 0x7fbb161e4250}, {SIG_DFL, [], 0}, 8) = 0
open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=106070960, ...}) = 0
mmap(NULL, 106070960, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fbb0fa73000
close(3)                                = 0
stat("/usr/share/mysql/charsets/Index.xml", {st_mode=S_IFREG|0644, st_size=18710, ...}) = 0
open("/usr/share/mysql/charsets/Index.xml", O_RDONLY) = 3
read(3, "<?xml version='1.0' encoding=\"ut"..., 18710) = 18710
close(3)                                = 0
futex(0xa4ae30, FUTEX_WAKE_PRIVATE, 2147483647) = 0
socket(AF_LOCAL, SOCK_STREAM, 0)        = 3
connect(3, {sa_family=AF_LOCAL, sun_path="/var/lib/mysql/mysql.sock"}, 110) = 0
setsockopt(3, SOL_TCP, TCP_NODELAY, [1], 4) = -1 EOPNOTSUPP (Operation not supported)
setsockopt(3, SOL_SOCKET, SO_KEEPALIVE, [1], 4) = 0
recvfrom(3, "N\0\0\0\n5.7.17-log\0F~\1\0008-dCPc\16-\0\377\367\10"..., 16384, 0, NULL, NULL) = 82
sendto(3, "\303\0\0\1\215\242\277\1\0\0\0\1!\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 199, 0, NULL, 0) = 199
recvfrom(3, "\22\0\0\2\0\0\0\2@\0\0\0\t\1\7\6db", 16384, 0, NULL, NULL) = 22
rt_sigaction(SIGINT, {0x408a80, [INT], SA_RESTORER|SA_RESTART, 0x7fbb161e4250}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGQUIT, {0x40a030, [QUIT], SA_RESTORER|SA_RESTART, 0x7fbb161e4250}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGHUP, {0x40a400, [HUP], SA_RESTORER|SA_RESTART, 0x7fbb161e4250}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGWINCH, {0x407300, [WINCH], SA_RESTORER|SA_RESTART, 0x7fbb161e4250}, {SIG_DFL, [], 0}, 8) = 0
ioctl(0, TIOCGWINSZ, 0x7ffe87d683f0)    = -1 ENOTTY (Inappropriate ioctl for device)
sendto(3, "!\0\0\0\3select @@version_comment li"..., 37, 0, NULL, 0) = 37
recvfrom(3, "\1\0\0\1\1'\0\0\2\3def\0\0\0\21@@version_comme"..., 16384, 0, NULL, NULL) = 92
read(0, "-- MySQL dump 10.13  Distrib 5.7"..., 4096) = 4096
stat("/etc/sysconfig/64bit_strstr_via_64bit_strstr_sse2_unaligned", 0x7ffe87d68150) = -1 ENOENT (No such file or directory)
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675466
sendto(3, "A\0\0\0\3/*!40101 SET @OLD_CHARACTER"..., 69, 0, NULL, 0) = 69
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675466
sendto(3, "C\0\0\0\3/*!40101 SET @OLD_CHARACTER"..., 71, 0, NULL, 0) = 71
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675466
sendto(3, "A\0\0\0\3/*!40101 SET @OLD_COLLATION"..., 69, 0, NULL, 0) = 69
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675466
sendto(3, "\33\0\0\0\3/*!40101 SET NAMES utf8 */", 31, 0, NULL, 0) = 31
recvfrom(3, "b\0\0\1\0\0\0\2@\0\0\0Y\0\32\24character_set_cl"..., 16384, 0, NULL, NULL) = 102
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675466
sendto(3, "+\0\0\0\3/*!40103 SET @OLD_TIME_ZONE"..., 47, 0, NULL, 0) = 47
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675466
sendto(3, "#\0\0\0\3/*!40103 SET TIME_ZONE='+00"..., 39, 0, NULL, 0) = 39
recvfrom(3, "\34\0\0\1\0\0\0\2@\0\0\0\23\0\21\ttime_zone\6+00:00", 16384, 0, NULL, NULL) = 32
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675466
sendto(3, "D\0\0\0\3/*!40014 SET @OLD_UNIQUE_CH"..., 72, 0, NULL, 0) = 72
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675466
sendto(3, "S\0\0\0\3/*!40014 SET @OLD_FOREIGN_K"..., 87, 0, NULL, 0) = 87
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675466
sendto(3, "K\0\0\0\3/*!40101 SET @OLD_SQL_MODE="..., 79, 0, NULL, 0) = 79
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675466
sendto(3, "8\0\0\0\3/*!40111 SET @OLD_SQL_NOTES"..., 60, 0, NULL, 0) = 60
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675466
sendto(3, "1\0\0\0\3DROP TABLE IF EXISTS `tAcco"..., 53, 0, NULL, 0) = 53
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675522
sendto(3, ">\0\0\0\3/*!40101 SET @saved_cs_clie"..., 66, 0, NULL, 0) = 66
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675522
sendto(3, ",\0\0\0\3/*!40101 SET character_set_"..., 48, 0, NULL, 0) = 48
recvfrom(3, "%\0\0\1\0\0\0\2@\0\0\0\34\0\32\24character_set_cl"..., 16384, 0, NULL, NULL) = 41
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675522
sendto(3, "V\2\0\0\3CREATE TABLE `tAccountingso"..., 602, 0, NULL, 0) = 602
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675609
sendto(3, "8\0\0\0\3/*!40101 SET character_set_"..., 60, 0, NULL, 0) = 60
recvfrom(3, "%\0\0\1\0\0\0\2@\0\0\0\34\0\32\24character_set_cl"..., 16384, 0, NULL, NULL) = 41
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675609
sendto(3, ".\0\0\0\3LOCK TABLES `tAccountingsof"..., 50, 0, NULL, 0) = 50
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675609
sendto(3, "A\0\0\0\3/*!40000 ALTER TABLE `tAcco"..., 69, 0, NULL, 0) = 69
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675609
sendto(3, "@\0\0\0\3/*!40000 ALTER TABLE `tAcco"..., 68, 0, NULL, 0) = 68
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675609
sendto(3, "\16\0\0\0\3UNLOCK TABLES", 18, 0, NULL, 0) = 18
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675609
sendto(3, "&\0\0\0\3DROP TABLE IF EXISTS `tActi"..., 42, 0, NULL, 0) = 42
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675623
sendto(3, ">\0\0\0\3/*!40101 SET @saved_cs_clie"..., 66, 0, NULL, 0) = 66
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675623
sendto(3, ",\0\0\0\3/*!40101 SET character_set_"..., 48, 0, NULL, 0) = 48
recvfrom(3, "%\0\0\1\0\0\0\2@\0\0\0\34\0\32\24character_set_cl"..., 16384, 0, NULL, NULL) = 41
read(0, "mediumint(8) unsigned NOT NULL,\n"..., 4096) = 4096
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675623
sendto(3, "\236\27\0\0\3CREATE TABLE `tActivesessio"..., 6050, 0, NULL, 0) = 6050
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
read(0, "lient = @saved_cs_client */;\n\n--"..., 4096) = 4096
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675701
sendto(3, "8\0\0\0\3/*!40101 SET character_set_"..., 60, 0, NULL, 0) = 60
recvfrom(3, "%\0\0\1\0\0\0\2@\0\0\0\34\0\32\24character_set_cl"..., 16384, 0, NULL, NULL) = 41
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675701
sendto(3, "#\0\0\0\3LOCK TABLES `tActivesession"..., 39, 0, NULL, 0) = 39
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675701
sendto(3, "6\0\0\0\3/*!40000 ALTER TABLE `tActi"..., 58, 0, NULL, 0) = 58
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675701
sendto(3, "5\0\0\0\3/*!40000 ALTER TABLE `tActi"..., 57, 0, NULL, 0) = 57
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675701
sendto(3, "\16\0\0\0\3UNLOCK TABLES", 18, 0, NULL, 0) = 18
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675701
sendto(3, ".\0\0\0\3DROP TABLE IF EXISTS `tActi"..., 50, 0, NULL, 0) = 50
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675714
sendto(3, ">\0\0\0\3/*!40101 SET @saved_cs_clie"..., 66, 0, NULL, 0) = 66
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675714
sendto(3, ",\0\0\0\3/*!40101 SET character_set_"..., 48, 0, NULL, 0) = 48
recvfrom(3, "%\0\0\1\0\0\0\2@\0\0\0\34\0\32\24character_set_cl"..., 16384, 0, NULL, NULL) = 41
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675714
sendto(3, "\316\1\0\0\3CREATE TABLE `tActivesessio"..., 466, 0, NULL, 0) = 466
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675734
sendto(3, "8\0\0\0\3/*!40101 SET character_set_"..., 60, 0, NULL, 0) = 60
recvfrom(3, "%\0\0\1\0\0\0\2@\0\0\0\34\0\32\24character_set_cl"..., 16384, 0, NULL, NULL) = 41
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675734
sendto(3, "+\0\0\0\3LOCK TABLES `tActivesession"..., 47, 0, NULL, 0) = 47
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675734
sendto(3, ">\0\0\0\3/*!40000 ALTER TABLE `tActi"..., 66, 0, NULL, 0) = 66
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675734
sendto(3, "=\0\0\0\3/*!40000 ALTER TABLE `tActi"..., 65, 0, NULL, 0) = 65
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675734
sendto(3, "\16\0\0\0\3UNLOCK TABLES", 18, 0, NULL, 0) = 18
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675734
sendto(3, ")\0\0\0\3DROP TABLE IF EXISTS `tAddi"..., 45, 0, NULL, 0) = 45
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675755
sendto(3, ">\0\0\0\3/*!40101 SET @saved_cs_clie"..., 66, 0, NULL, 0) = 66
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675755
sendto(3, ",\0\0\0\3/*!40101 SET character_set_"..., 48, 0, NULL, 0) = 48
recvfrom(3, "%\0\0\1\0\0\0\2@\0\0\0\34\0\32\24character_set_cl"..., 16384, 0, NULL, NULL) = 41
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675755
sendto(3, "I\6\0\0\3CREATE TABLE `tAdditionalin"..., 1613, 0, NULL, 0) = 1613
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675802
sendto(3, "8\0\0\0\3/*!40101 SET character_set_"..., 60, 0, NULL, 0) = 60
recvfrom(3, "%\0\0\1\0\0\0\2@\0\0\0\34\0\32\24character_set_cl"..., 16384, 0, NULL, NULL) = 41
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675802
sendto(3, "&\0\0\0\3LOCK TABLES `tAdditionalinc"..., 42, 0, NULL, 0) = 42
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675802
sendto(3, "9\0\0\0\3/*!40000 ALTER TABLE `tAddi"..., 61, 0, NULL, 0) = 61
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675802
sendto(3, "8\0\0\0\3/*!40000 ALTER TABLE `tAddi"..., 60, 0, NULL, 0) = 60
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675802
sendto(3, "\16\0\0\0\3UNLOCK TABLES", 18, 0, NULL, 0) = 18
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675802
sendto(3, "3\0\0\0\3DROP TABLE IF EXISTS `tAddi"..., 55, 0, NULL, 0) = 55
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675817
sendto(3, ">\0\0\0\3/*!40101 SET @saved_cs_clie"..., 66, 0, NULL, 0) = 66
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675817
sendto(3, ",\0\0\0\3/*!40101 SET character_set_"..., 48, 0, NULL, 0) = 48
recvfrom(3, "%\0\0\1\0\0\0\2@\0\0\0\34\0\32\24character_set_cl"..., 16384, 0, NULL, NULL) = 41
read(0, "ed DEFAULT NULL,\n  `fkiAgentIDRe"..., 4096) = 4096
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675817
sendto(3, "\356\7\0\0\3CREATE TABLE `tAdditionalin"..., 2034, 0, NULL, 0) = 2034
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675888
sendto(3, "8\0\0\0\3/*!40101 SET character_set_"..., 60, 0, NULL, 0) = 60
recvfrom(3, "%\0\0\1\0\0\0\2@\0\0\0\34\0\32\24character_set_cl"..., 16384, 0, NULL, NULL) = 41
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675888
sendto(3, "0\0\0\0\3LOCK TABLES `tAdditionalinc"..., 52, 0, NULL, 0) = 52
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675888
sendto(3, "C\0\0\0\3/*!40000 ALTER TABLE `tAddi"..., 71, 0, NULL, 0) = 71
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675888
sendto(3, "B\0\0\0\3/*!40000 ALTER TABLE `tAddi"..., 70, 0, NULL, 0) = 70
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675888
sendto(3, "\16\0\0\0\3UNLOCK TABLES", 18, 0, NULL, 0) = 18
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675888
sendto(3, "6\0\0\0\3DROP TABLE IF EXISTS `tAddi"..., 58, 0, NULL, 0) = 58
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675904
sendto(3, ">\0\0\0\3/*!40101 SET @saved_cs_clie"..., 66, 0, NULL, 0) = 66
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675904
sendto(3, ",\0\0\0\3/*!40101 SET character_set_"..., 48, 0, NULL, 0) = 48
recvfrom(3, "%\0\0\1\0\0\0\2@\0\0\0\34\0\32\24character_set_cl"..., 16384, 0, NULL, NULL) = 41
read(0, "AULT CHARSET=utf8;\n/*!40101 SET "..., 4096) = 4096
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675904
sendto(3, "\"\10\0\0\3CREATE TABLE `tAdditionalin"..., 2086, 0, NULL, 0) = 2086
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675977
sendto(3, "8\0\0\0\3/*!40101 SET character_set_"..., 60, 0, NULL, 0) = 60
recvfrom(3, "%\0\0\1\0\0\0\2@\0\0\0\34\0\32\24character_set_cl"..., 16384, 0, NULL, NULL) = 41
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675977
sendto(3, "3\0\0\0\3LOCK TABLES `tAdditionalinc"..., 55, 0, NULL, 0) = 55
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675977
sendto(3, "F\0\0\0\3/*!40000 ALTER TABLE `tAddi"..., 74, 0, NULL, 0) = 74
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675977
sendto(3, "E\0\0\0\3/*!40000 ALTER TABLE `tAddi"..., 73, 0, NULL, 0) = 73
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675977
sendto(3, "\16\0\0\0\3UNLOCK TABLES", 18, 0, NULL, 0) = 18
recvfrom(3, "\7\0\0\1\0\0\0\2\0\0\0", 16384, 0, NULL, NULL) = 11
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 611675977
sendto(3, " \0\0\0\3DROP TABLE IF EXISTS `tAddr"..., 36, 0, NULL, 0) = 36
recvfrom(3, ^Cstrace: Process 5586 detached
 <detached ...>
[root@dev dev]# ^C -- query aborted
^C
[root@dev dev]#
In that trace, I sent the password interactively, and the sql file in stdin like this

mysql -u user -p db < a.sql

Last edited by Herrick19; 02-18-2018 at 04:51 PM.
 
Old 02-18-2018, 04:48 PM   #8
Herrick19
LQ Newbie
 
Registered: Feb 2018
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by astrogeek View Post
Perhaps the OP could tell us more about what their actual goals and constraints are as well.
Hi,

I am building a web interface so that level 1 technicians can restore customer backups to test database to reproduce problems or help customers by trying stuff first.

Usually, I run the restore manually form the command line like this

mysql -u user -p db < a.sql

I don't want to give them ssh access so I'm trying to reproduce this in a Web interface using php.

I don't want the password to be visible if someone is doing a "ps -aux" and I would prefer not writing the password in clear text in a text file like other posts suggest.

And yes, I know PHP can connect to mysql, but files I need to restore are several gigs, it's easier to just redirect the sql file to the mysql binary.

Thanks
 
Old 02-18-2018, 05:38 PM   #9
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Restoring several gigs database backup may take resources and time. I would set up a cron job for this.
For interfacing with web page, I'd use a php script that update a mysql table value to 1 and a cron job that read periodically this value in the table. If this value is 1, then a backup is sheduled (at a time when it doesn't slow down other services)

Just an idea, for mysql password I'd go with --defaults-file option, making sure config file is located outside the web documents and restrictive permissions are set
 
Old 02-18-2018, 06:05 PM   #10
Herrick19
LQ Newbie
 
Registered: Feb 2018
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by keefaz View Post
Restoring several gigs database backup may take resources and time. I would set up a cron job for this.
For interfacing with web page, I'd use a php script that update a mysql table value to 1 and a cron job that read periodically this value in the table. If this value is 1, then a backup is sheduled (at a time when it doesn't slow down other services)

Just an idea, for mysql password I'd go with --defaults-file option, making sure config file is located outside the web documents and restrictive permissions are set
Thanks for your comment, but discussion is moving away from my need... I just need someone that understand how the MySQL cli client is able to retrieve the password from tty and the source file from stdin.

From there, I'll try to reproduce the functionnality using proc_open with multiple file descriptors

Thanks
 
Old 02-18-2018, 08:13 PM   #11
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Instead of reading file via stdin, you could use a source file query?
 
1 members found this post helpful.
Old 02-19-2018, 02:55 PM   #12
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,671
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
One of the key principles of working with "child processes that you do not own" is ... "do not attempt to do their work for them." For instance, the MySQL command-line interface program already has a source filename subcommand. Therefore, you should simply arrange to use this subcommand to "tell the child what to do." Don't do its thinking for it.
 
Old 02-19-2018, 03:06 PM   #13
Herrick19
LQ Newbie
 
Registered: Feb 2018
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by keefaz View Post
Instead of reading file via stdin, you could use a source file query?
Thanks, it worked...
I'm sending the password to stdin but I'm using -e "source /tmp/a.sql" on the command line to load the file so I don't need to try to send it to stdin...

I'm still curious about how it works, but at least it works.

Thanks to all
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can ls take input from stdin? stf92 Linux - Newbie 9 07-05-2011 08:37 AM
[SOLVED] specifying output int based on input int and source IP on multiple 802.1q, tacorama Linux - Networking 1 05-05-2011 07:30 AM
gzip: stdin: Input/output error,what does it mean? ayongying Linux - Newbie 11 03-03-2010 12:13 AM
[SOLVED] send signal every time input comes in on stdin crs_zxf Programming 9 11-08-2009 03:58 AM
How to make extra stdin input in awk ? khaan Programming 3 07-30-2007 05:04 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration