qemu-mipsel-static can't find /dev/urandom - mips

I tried to run binary file with qemu-mipsel-static :
qemu-mipsel-static -L ../ ./MyBinary
But process is crashed when it tried to access to /dev/urandom
│access("../dev/urandom", F_OK) = -1 ENOENT (No such file or directory)
How can I fix that?

Related

I have written a line in nano /etc/my.cnf file and how I'm not able to remove it

I have added secure-file-priv = "" to my nano /etc/my.cnf file for mysql and now I'm not able to remove it.When I remove that line and try to save it, it's asking me to write to a file and the changes are not saved
I tried to uninstall and install mySQL but due to this the server is not able to start.
Error Messages:
my_print_defaults: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1.
my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
Starting MySQL
.my_print_defaults: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1.
my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
my_print_defaults: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1.
my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
Is there any way I can fix this error, I tried a lot but couldn't find any solution
"errors when saving" are often linked to access rights issues.
run ls -l /etc/my.cnf to confirm that this file is owned by root.
in the vast majority of cases, system wide configuration files are owned by root. To edit a root file, you should do it with root privileges, e.g :
sudo nano /etc/my.cnf
(that's probably how you were able to add the config parameter in the first place)

split a single file to multiple files by key name

I have a huge json file which has its keys starting with a "/". I wanted to create multiple json file based on the key name.
/upgrade-coordinator/api/v1/upgrade/eula/acceptance
/upgrade-coordinator/api/v1/upgrade/history
/upgrade-coordinator/api/v1/upgrade/nodes
/upgrade-coordinator/api/v1/upgrade/nodes-summary
/upgrade-coordinator/api/v1/upgrade/status-summary
/upgrade-coordinator/api/v1/upgrade/summary
/upgrade-coordinator/api/v1/upgrade/upgrade-unit-groups
/upgrade-coordinator/api/v1/upgrade/upgrade-unit-groups-status
Following some note in the site, I came across:
for f in `cat input.json | jq -r 'keys[]'` ; do
cat input.json | jq ".$f" > $f.json
done
or when you insist on more bashy syntax like some seem to prefer:
for f in $(jq -r 'keys[]') ; do
jq ".[\"$f\"]" < input.json > "$f.json"
done < input.json
When I tried the above, I get the error:
-bash: -/nsxapi/api/v1/vpn/l2vpn/sessions/summary.json: No such file or directory
-bash: -/upgrade-coordinator/api/v1/upgrade/eula/acceptance.json: No such file or directory
-bash: -/upgrade-coordinator/api/v1/upgrade/history.json: No such file or directory
-bash: -/upgrade-coordinator/api/v1/upgrade/nodes.json: No such file or directory
-bash: -/upgrade-coordinator/api/v1/upgrade/nodes-summary.json: No such file or directory
-bash: -/upgrade-coordinator/api/v1/upgrade/status-summary.json: No such file or directory
-bash: -/upgrade-coordinator/api/v1/upgrade/summary.json: No such file or directory
-bash: -/upgrade-coordinator/api/v1/upgrade/upgrade-unit-groups.json: No such file or directory
-bash: -/upgrade-coordinator/api/v1/upgrade/upgrade-unit-groups-status.json: No such file or directory
-bash: -/upgrade-coordinator/api/v1/upgrade/upgrade-unit-groups/aggregate-info.json: No such file or directory
-bash: -/upgrade-coordinator/api/v1/upgrade/upgrade-units.json: No such file or directory
-bash: -/upgrade-coordinator/api/v1/upgrade/upgrade-units-stats.json: No such file or directory
-bash: -/upgrade-coordinator/api/v1/upgrade/upgrade-units/aggregate-info.json: No such file or directory
I think its probably bcos, its looking to create aggregate-info.json in the path -/upgrade-coordinator/api/v1/upgrade/upgrade-units/ -- If this is correct, how do I replace the first string "/" in every key to a blank space? Can I get some help, please?
It means - to take the first error message as example -, that the directory -/nsxapi/api/v1/vpn/l2vpn/sessions does not exist. You could verify this by doing a
ls -d -- -/nsxapi/api/v1/vpn/l2vpn/sessions
in the working directory, where your script runs.
Note that a redirection to some path does not automatically create intermittent directories.

MySQL not picking up symlinked cnf changes in 5.7.13 on Ubuntu 16.04

EDIT: I may have found what might be part of the issue, further edit at the bottom.
I've got a new server setup running mysql everything seems to be okay. Except whenever I use show variables the configuration settings I can see in my .cnf file are not being shown and what appear to be general defaults are being shown. So it would appear while I can use mysql just fine, the settings are all just the defaults.
I am trying to figure out why my .cnf is not being used. I have taken a number of steps to check that it is definitely being loaded and these are laid out below. Once I am sure it is being loaded I am at a loss as to how to explain why my settings aren't being used. Any help would be greatly appreciated.
The location of my cnf file is this:
/etc/mysql/mysql.conf.d/mysqld.cnf
I have attempted to verify that this is what is being used by the following:
sudo /usr/sbin/mysqld --verbose --help | grep -A 1 "Default options"
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf ~/.my.cnf
/etc/my.cnf does not exist
/etc/mysql/my.cnf is a symlink to /etc/alternatives/my.cnf
/etc/alternatives/my.cnf is a symlink to /etc/mysql/mysql.cnf
/etc/mysql/mysql.cnf contains:
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
etc/mysql/conf.d/ is a directory that contains:
mysql.cnf
mysqldump.cnf
mysql.cnf is empty so presumably isn’t doing anything
/etc/mysql/mysql.conf.d/ is a directory that contains:
mysqld.cnf
mysqld.cnf.dpkg-new
mysqld_safe_syslog.cnf
mysqld.cnf is a symlink to /home/{my_username}/conf/mysqld.cnf
/home/{my_username}/conf/mysqld.cnf is my conf file which I expect it to be using.
So I cannot see the problem it looks like it should be using my config.
In a second attempt to verify that this .cnf is being used I used strace mysql. My file was listed and opened along with the other paths I just listed above.
stat("/etc/mysql/mysql.conf.d/mysqld.cnf", {st_mode=S_IFREG|0664, st_size=2262, ...}) = 0
open("/etc/mysql/mysql.conf.d/mysqld.cnf", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0664, st_size=2262, ...}) = 0
read(4, "# Generated by Percona Configura"..., 4096) = 2262
read(4, "", 4096) = 0
close(4) = 0 close(4)
Again it looks like it should be using the .cnf file.
Can anyone offer any insight into why it's not?
EDIT: I've just done a strace mysqld instead of strace mysql and I get a permission error on my .cnf file. This could be the problem. But I don't understand enough about the difference between mysql and mysqld can anyone explain?
stat("/etc/mysql/mysql.conf.d/mysqld.cnf", {st_mode=S_IFREG|0664, st_size=3218, ...}) = 0
open("/etc/mysql/mysql.conf.d/mysqld.cnf", O_RDONLY) = -1 EACCES (Permission denied)
This was caused and resolved by apparmor
Ubuntu comes with something called AppArmor, a kernel-integrated
application security system that controls how applications can access
the file system. Source: Oracle Article
If you put the .cnf in a custom location, you need to give mysql permissions to access that directory. In my case I needed to edit this /etc/apparmor.d/local/usr.sbin.mysqld with the following:
/home/{my_username}/conf/mysqld.cnf r
You could also use:
/home/{my_username}/conf/* r
To give it access to the whole directory.

Docker and Mysql: libz.so.1: cannot open shared object file: Permission denied

When running mysqld in this Dockerfile (on my Linux box, Linux 12.04)
Dockerfile:
FROM ubuntu:precise
RUN apt-get update
RUN apt-get install -y mysql-server
CMD ["/usr/sbin/mysqld"]
I get mysqld: error while loading shared libraries: libz.so.1: cannot open shared object file: Permission denied
Whereas running it on my Mac through boot2docker mysqld starts up just fine.
I have tried different base docker images:
phusion/baseimage:0.9.8
phusion/baseimage:0.9.1
ubuntu:latest
I have run apt-get update and apt-get upgrade (including updating Mysql) on the host system, I have rebooted the host system.
Any ideas on how to proceed?
Info about my system:
$ docker version
Client version: 0.9.0
Go version (client): go1.2.1
Git commit (client): 2b3fdf2
Server version: 0.9.0
Git commit (server): 2b3fdf2
Go version (server): go1.2.1
Last stable version: 0.9.0
$ docker info
Containers: 37
Images: 340
Driver: aufs
Root Dir: /var/lib/docker/aufs
Dirs: 414
WARNING: No swap limit support
$ uname -a
Linux Ubuntu-1204-precise-64-minimal 3.8.0-37-generic #53~precise1-Ubuntu SMP Wed Feb 19 21:37:54 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
Answer to leeduhem comments about permissions of libz.so.1:
$ ls -l /lib/x86_64-linux-gnu/libz.so.1
lrwxrwxrwx 1 root root 15 Nov 10 2011 /lib/x86_64-linux-gnu/libz.so.1 -> libz.so.1.2.3.4
$ ls -l /lib/x86_64-linux-gnu/libz.so.1.2.3.4
-rw-r--r-- 1 root root 92720 Nov 10 2011 /lib/x86_64-linux-gnu/libz.so.1.2.3.4
Changing permissions with
$ chmod +x /lib/x86_64-linux-gnu/libz.so.1.2.3.4
I still get the error.
Running strace -o /tmp/mysql.strace mysqld and cat /tmp/mysql.strace gives
execve("/usr/sbin/mysqld", ["mysqld"], [/* 7 vars */]) = 0
brk(0) = 0x7f4d41f7c000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4d403c5000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = -1 EACCES (Permission denied)
open("/lib/x86_64-linux-gnu/tls/x86_64/libz.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64-linux-gnu/tls/x86_64", 0x7fff713907f0) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/tls/libz.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64-linux-gnu/tls", 0x7fff713907f0) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/x86_64/libz.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64-linux-gnu/x86_64", 0x7fff713907f0) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libz.so.1", O_RDONLY|O_CLOEXEC) = -1 EACCES (Permission denied)
stat("/lib/x86_64-linux-gnu", 0x7fff713907f0) = -1 EACCES (Permission denied)
open("/usr/lib/x86_64-linux-gnu/tls/x86_64/libz.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu/tls/x86_64", 0x7fff713907f0) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64-linux-gnu/tls/libz.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu/tls", 0x7fff713907f0) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64-linux-gnu/x86_64/libz.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu/x86_64", 0x7fff713907f0) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64-linux-gnu/libz.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu", 0x7fff713907f0) = -1 EACCES (Permission denied)
open("/lib/tls/x86_64/libz.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/tls/x86_64", 0x7fff713907f0) = -1 ENOENT (No such file or directory)
open("/lib/tls/libz.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/tls", 0x7fff713907f0) = -1 ENOENT (No such file or directory)
open("/lib/x86_64/libz.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64", 0x7fff713907f0) = -1 ENOENT (No such file or directory)
open("/lib/libz.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib", 0x7fff713907f0) = -1 EACCES (Permission denied)
open("/usr/lib/tls/x86_64/libz.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/tls/x86_64", 0x7fff713907f0) = -1 ENOENT (No such file or directory)
open("/usr/lib/tls/libz.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/tls", 0x7fff713907f0) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64/libz.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64", 0x7fff713907f0) = -1 ENOENT (No such file or directory)
open("/usr/lib/libz.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib", 0x7fff713907f0) = -1 EACCES (Permission denied)
writev(2, [{"mysqld", 6}, {": ", 2}, {"error while loading shared libra"..., 36}, {": ", 2}, {"libz.so.1", 9}, {": ", 2}, {"cannot open shared object file", 30}, {": ", 2}, {"Permission denied", 17}, {"\n", 1}], 10) = 107
Looking at the directories /lib and /lib/x86_64-linux-gnu that the trace seems to indicate are not permitted:
$ ls -ld /lib
drwxr-xr-x 12 root root 4096 Dec 16 13:42 /lib
$ ls -ld /lib/x86_64-linux-gnu
drwxr-xr-x 3 root root 4096 Mar 17 13:39 /lib/x86_64-linux-gnu
Deleting the container solve this problem for me.
Update: That solution worked not so long.
So I kept searching and found something related with Apparmor.
If you have mysql installed on your host, Apparmor may restrict access of this shared library for mysql installed on your docker container. The following fixed the problem:
#Type this on your host terminal
sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
So I solved the issue by using the devicemapper storage backend, as suggested by #jpetazzo.
Steps I carried out:
Stopped the docker deamon
Started the docker deamon with command docker -d -s="devicemapper"
Ran the docker run on the Dockerfile command again. And it worked without any problems.
If you have mysql-server installed on your host machine, then it installs an apparmor profile for mysqld. For me, the problem went away after I disabled the mysqld apparmor profile on the host with the following commands:
sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
Of course, this also means that apparmor will be disabled for mysqld on your host. I don't use mysqld so I'm okay with that.
Try
sudo apt-get update
sudo apt-get install -y mysql-server

Can't create/write to file '/var/lib/mysql/aria_log_control'

Something is wrong. I stopped MaridaDB, moved /var/lib/mysql to a different place, then replaced the old mysql with a softlink
cd /var/lib
ln -s /data/mysql .
Then I added
chown -R mysql:mysql mysql
and then I went to /data and did the same (Note: this relocation works fine in regular mysql). But in MariaDB
ERROR] mysqld: Can't create/write to file
'/var/lib/mysql/aria_log_control' (Errcode: 13 "Permission denied")
[ERROR] mysqld: Got error 'Can't create file' when trying to use aria
control file '/var/lib/mysql/aria_log_control' [ERROR] Plugin 'Aria'
init function returned error. [ERROR] Plugin 'Aria' registration as a
STORAGE ENGINE failed.
So what can I do to fix this? I tried setting
chmod 777 /var/lib/mysql/aria_log_control
but to no avail.
In my case the problem was that while directory mysql and files within were owned by user mysql, the path has a directory that lacked x bit for the users that are not in the correct group. In other words, user could not move to the target directory because one of the directories in the path did not allow it.
In My case this happened after a change which required OS restart, turned out that SELINUX was in ENFORCE mode and was not allowing MySQL to access the files, used below command to resolve:
sudo getenforce
sudo setenforce 0