Cannot open firefox browser via X11 - amazon-web-services

When I try to start firefox on ec2 instance (centos/7) via X11, I got an error.
Is there a way to solve this?
I'm already confirmed that other GUI application, sucy as xeyes or eog, can be launched.
Env
ec2 side
OS: Centos 7.3.1611 (Core)
SELinux: Enforcing
xauth version: 1.0.9
xterm version: X.Org 7.6.0(295)
xorg-x11-apps.x86_64: 7.7-6.el7
$ sudo cat /etc/ssh/sshd_config
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
SyslogFacility AUTHPRIV
AuthorizedKeysFile .ssh/authorized_keys
PasswordAuthentication no
ChallengeResponseAuthentication no
GSSAPIAuthentication yes
GSSAPICleanupCredentials no
UsePAM yes
X11Forwarding yes
X11UseLocalhost no
UsePrivilegeSeparation sandbox # Default for new installations.
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS
Subsystem sftp /usr/libexec/openssh/sftp-server
local side
OS: Mac OS X 10.11.6
XQuartz version: 2.7.11 (xorg-server 1.18.4)
$ sudo cat /etc/ssh/sshd_config
# Apple:
Host *
SendEnv LANG LC_*
Host *
XAuthLocation /opt/X11/bin/xauth
Reproduction scenario
# ec2 side
sudo yum -y install xauth xterm xorg-x11-apps xeyes
exit
# local side
ssh -X fhiyo#ec2-xx-xx-xx-xx.ap-northeast-1.compute.amazonaws.com
# ec2 side
xeyes # OK
sudo yum -y install eog
eog path/to/sample.png # OK
sudo yum -y install firefox
$ firefox
[Parent 20819] WARNING: pipe error (36): Connection reset by peer: file /builddir/build/BUILD/firefox-52.2.0/firefox-52.2.0esr/ipc/chromium/src/chrome/common/ipc_channel_posix.cc, line 322
###!!! [Parent][MessageChannel] Error: (msgtype=0x46000E,name=PContent::Msg_NotifyLayerAllocated) Channel error: cannot send/recv
...
[Parent 20819] WARNING: FileDescriptorSet destroyed with unconsumed descriptors: file /builddir/build/BUILD/firefox-52.2.0/firefox-52.2.0esr/ipc/chromium/src/chrome/common/file_descriptor_set_posix.cc, line 22
###!!! [Parent][MessageChannel] Error: (msgtype=0x2C0085,name=PBrowser::Msg_Destroy) Channel error: cannot send/recv

I had a similar problem when launching Firefox version 52.3.0 with X11 forwarding on CentOS 7 :
WARNING: pipe error (35): Connexion ré-initialisée par le correspondant: file /builddir/build/BUILD/firefox-52.3.0/firefox-52.3.0esr/ipc/chromium/src/chrome/common/ipc_channel_posix.cc, line 322
And same error (in french) on firefox "Gah, you tab just crash"
To correct this, i tried first to update all the package without success.
So i combined two solutions i found on the net :
1- I opened the "about:config" page (just type about:config in the url field then enter) and changed to "false" the 2 options browser.tabs.config.autostart and browser.tabs.config.autostart2
2- I opened the "about:support" page and click on "Repair Firefox..."
Then it works ! but i still have the following problem : i need to do this each time i relaunch firefox; So i should not close all tabs.

Check your SELinux configuration. In special check that mozilla_plugin_can_network_connect is enabled. You can do: getsebool mozilla_plugin_can_network_connect if answer is off then do setsebool -P mozilla_plugin_can_network_connect=1. Then try again firefox&

Related

Postgresql 9.3 on ubuntu for Django web application Error: cluster_port_ready: could not find psql binary

I'm having some issues with postgresql 9.3 running on ubuntu 14.04.5
I had a django web application running using NGINX/Gunicorn, for a few weeks, then one day I went to use it and I got an OperationalError:
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
After researching, it became apparent that the postgresql server wasn't running. I then attempted to start it, and got the following error:
* No PostgreSQL clusters exist; see "man pg_createcluster"
Alarming, but my data is backed up just fine, so I did:
pg_createcluster 9.3 main --start
and then I got:
Error: cluster configuration already exists
No problem. I'll drop it and create a new one, I thought:
pg_dropcluster 9.3 main --stop
that ran fine, and so I ran:
pg_createcluster 9.3 main --start
again, and now it created the cluster apparently, but would not start:
Creating new cluster 9.3/main ...
config /etc/postgresql/9.3/main
data /var/lib/postgresql/9.3/main
locale en_US.UTF-8
port 5432
Error: cluster_port_ready: could not find psql binary
does anyone have any advice as to how to address this? I have done apt-get remove and install for postgresql, and still same results.
Thanks in advance!
UPDATE:
So, I tried the suggestion below to run the following:
/usr/lib/postgresql/9.3/bin/initdb -D /var/lib/postgresql/data -W -A md5
which returned:
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale "C".
The default database encoding has accordingly been set to "SQL_ASCII".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
creating configuration files ... ok
creating template1 database in /var/lib/postgresql/data/base/1 ... ok
initializing pg_authid ... ok
Enter new superuser password:
Enter it again:
setting password ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating collations ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
loading PL/pgSQL server-side language ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
syncing data to disk ... ok
Success. You can now start the database server using:
/usr/lib/postgresql/9.3/bin/postgres -D /var/lib/postgresql/data
or
/usr/lib/postgresql/9.3/bin/pg_ctl -D /var/lib/postgresql/data -l logfile start
So I ran:
user$ /usr/lib/postgresql/9.3/bin/postgres -D /var/lib/postgres
ql/data
and got:
LOG: could not bind IPv6 socket: Address already in use
HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
LOG: could not bind IPv4 socket: Address already in use
HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
WARNING: could not create listen socket for "localhost"
FATAL: could not create any TCP/IP sockets
So I was unable to recover the postgres instance I was trying to run, so I used this stack overflow article on
How to purge and thoroughly uninstall postgres
. As far as why this happened, I am still at a loss. I read that my issue could have been caused by my locale environment variables for LANGUAGE, and LANG_ALL. Or it's possible that this could have been caused after an update because I didn't specify what version of postgres I wanted to install when I ran apt-get initially. Regardless, here are the commands I ran that got me back into business:
apt-get --purge remove postgresql\*
After this command, I got some errors complaining about an invalid data directory again, so on the advice of a post that's not marked as the answer from the link above, I also ran:
apt-get autoremove postgresql*
That seemed to go well, so I returned to the instructions as laid out by the accepted answer:
rm -r /etc/postgresql/
rm -r /etc/postgresql-common/
rm -r /var/lib/postgresql/
userdel -r postgres
groupdel postgres
That appeared to complete without errors, except that the postgres user had already been removed by the previous commands..
I then ensured that my locale environment variables were set, based on an a related article titled: Solving "no PostgresSQL Clusters found" error
I ran:
#dpkg-reconfigure locales
Once that was all finished, I did a fresh install, this time specifying the version number:
apt-get install postgresql-9.3 postgresql-contrib-9.3 postgresql-doc-9.3
after the install completed postgres started automatically, and it seems to be fine now.
create postgresql database cluster:
$ sudo su
# mkdir /var/lib/postgresql/data
# chown -R postgres:postgres /var/lib/postgresql/data
# su postgres
$ /usr/lib/postgresql/9.3/bin/initdb -D /var/lib/postgresql/data -W -A md5
If this error messages:
LOG: could not bind IPv4 socket: Address already in use
It mean postgresql already running, you need to restart it.
You can restart service postgresql in ubuntu 14.04 with this command:
$ sudo sh /etc/init.d/postgresql restart
In new Ubuntu with systemd, to restart postgresql with this command:
$ sudo systemctl restart postgresql

Ansible configuration failed in Ubuntu 16.04LTS

Im new to Devops and im learning the Ansible as a beginner with AWS EC2 Ubuntu 16.04 LTS.
initially i have launched 2 EC2 instances with SSH port 22 open in security group, i named the instances as Master and Slave.
I ssh'ed into Master Instances when all is up and running.
I will list steps one by one as follow
1. I created a user called ansible and issued password
ubuntu#ip-172-31-17-94:~$ sudo su
root#ip-172-31-17-94:/home/ubuntu# adduser ansible
Adding user `ansible' ...
Adding new group `ansible' (1001) ...
Adding new user `ansible' (1001) with group `ansible' ...
Creating home directory `/home/ansible' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for ansible
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n]
2. uncommented PermitRootLogin yes and PasswordAuthentication yes in /etc/ssh/sshd_config and restarted ssh
3.Changed the Visudo file adding root access to ansible user
root#ip-172-31-17-94:/home/ubuntu# visudo
edited
# User privilege specification
root ALL=(ALL:ALL) ALL
ansible ALL=(ALL:ALL) ALL
saved and closed
4.Generated ssh keygen
ansible#ip-172-31-17-94:~$ ssh-keygen -t rsa -b 4096
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ansible/.ssh/id_rsa):
Created directory '/home/ansible/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/ansible/.ssh/id_rsa.
Your public key has been saved in /home/ansible/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:wah0yD9Ngf7hzLIihkEFvNYjPNrzcLubNxGnqFKYrik ansible#ip-172-31-17-94
The key's randomart image is:
+---[RSA 4096]----+
|... .. |
| . o ..o . |
|. + +.o + |
| B + +ooo. |
|++o o.oOS. |
|= = o +.= |
|.+ * . + |
|Eo+ +.+ |
|=o .+= . |
+----[SHA256]-----+
5. Installing Ansible packages
$ sudo apt-get install software-properties-common
$ sudo apt-add-repository ppa:ansible/ansible
$ sudo apt-get update
$ sudo apt-get install ansible
Awesome!.. all is up and ansible is install in master server
I issued a command to test the ansible
ansible#ip-172-31-17-94:~$ ansible --version
ansible 2.3.0.0
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides
python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]
6. Edited the /etc/ansible/hosts and added my slave server private ip (My ec2 are in same subnet in same availability zone ) so i used private Ip
[my]
172.31.29.197
.save and closed
7.ssh'ed in Slave Server and repeated the 1, 2 ,3 steps and logout
8.shh'ed into Master server
local#host $ shh ansible#<Master Ip>
9.Copying public Key to the Slave Server from Master server
ansible#ip-172-31-17-94:~$ ssh-copy-id 172.31.29.197
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/ansible/.ssh/id_rsa.pub"
The authenticity of host '172.31.29.197 (172.31.29.197)' can't be established.
ECDSA key fingerprint is SHA256:qOW0ZktetcpTNmxRsubxn1kcr8egyNmcA5Uk9+oWc7A.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
ansible#172.31.29.197's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '172.31.29.197'"
and check to make sure that only the key(s) you wanted were added
ansible#ip-172-31-17-94:~$ ssh 172.31.29.197
Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-1013-aws x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
Get cloud support with Ubuntu Advantage Cloud Guest:
http://www.ubuntu.com/business/services/cloud
14 packages can be updated.
12 updates are security updates.
Last login: Sat Apr 22 06:27:15 2017 from 42.109.141.238
ansible#ip-172-31-29-197:~$ logout
Connection to 172.31.29.197 closed.
And successfully configured the Mater to Slave password-less ssh connection
Till then i haven't faced any issue.
when i issued a command Ansible -m ping all
i got an error
172.31.29.197 | FAILED! => {
"changed": false,
"failed": true,
"module_stderr": "Shared connection to 172.31.29.197 closed.\r\n",
"module_stdout": "/bin/sh: 1: /usr/bin/python: not found\r\n",
"msg": "MODULE FAILURE",
"rc": 0
}
later when i gooogled i got some chunks i followed listed step by the solution.
the solution is i repeated step no.5 from above list in slave server. when issued ansible -m ping from the Master server i got success Message
My question that how to install agent-less anible in a Slave, The main feature of ansible agent-less!
Help me if i missed any of step
You need to install Python 2 on 172.31.29.197.
Or (in a less likely case) if it is installed in a path different than /usr/bin/python you need to add ansible_python_interpreter parameter pointing to the right executable to your inventory file.

Why shouldn't I use timedatectl to set the timezone

When I use timedatectl to set the timezone, it happens
[root#localhost ~]# timedatectl set-timezone "America/New_York"
Failed to set time zone: Access denied
This's my host infomation
Static hostname: rolin
Icon name: computer-vm
Chassis: vm
Machine ID: 699591c5339c2ae6d7e7b25151eaa987
Boot ID: 40dc52c07c85444c9514f7d92a24448e
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-327.18.2.el7.x86_64
Architecture: x86-64
What can I do now?
The root cause of this problem is probably an SELinux labeling issue. The fix is to relabel the /etc directory:
restorecon -Rv /etc
Then re-run the timedatectl command.
Source: https://access.redhat.com/solutions/3366211 (link requires a RedHat login).
Or if you can't do that for some reason, as a workaround you could temporarily set SELinux to permissive mode, update the time zone, and then re-enable SELinux.
However, that second approach will not fix the underlying problem. A mis-labeling in /etc may well cause other problems down the road.
I find that my /etc/localtime is not a symbolic links pointing to /usr/share/zoneinfo/... .
so I changed that file like this ,it works:
lrwxrwxrwx. /etc/localtime ->../usr/share/zoneinfo/Asia/Shanghai
I used this commands to change timezone for my vicidial server with cent os 7 :
rm /etc/localtime
rm: remove regular file `/etc/localtime'
ln -s /usr/share/zoneinfo/Europe/Rome localtime
date
and you will see that it is changed.

OSError: [Errno 13] Permission denied: '/dev/ttyACM0' - using pyserial from Python to Arduino

Environment
Linux Mint 17.1
Python 2.7
pyserial 2.7
Arduino UNO rv3
Desired Behaviour
I'm trying to send three values from a Python application to Arduino.
It works when doing the following from terminal:
$ python
$ import serial
$ import struct
$ ser = serial.Serial('/dev/ttyACM0', 9600)
$ ser.write(struct.pack('>3B', 255, 0, 0))
Current Behaviour
It doesn't work when using the same code in a Python file ie:
import serial
import struct
ser = serial.Serial('/dev/ttyACM0', 9600)
ser.write(struct.pack('>3B', red_value, green_value, blue_value))
Error Message
$ sudo tail -100 /var/log/apache2/error.log
OSError: [Errno 13] Permission denied: '/dev/ttyACM0'
Troubleshooting
Permissions
Application file:
$ ls -l
-rwxr-xr-x 1 myname mygroupname 114146 Jan 9 19:16 my_application.py
ttyACM0:
ls -l /dev/ttyACM0
crw-rw---- 1 root dialout 166, 0 Jan 9 20:12 /dev/ttyACM0
Groups
Groups the owner is a member of:
$ groups
mygroupname adm dialout cdrom sudo dip plugdev lpadmin sambashare
Due to various suggestions on the internet I also added the owner to the tty group via System Settings > Users and Groups. This had no effect.
Serial Ports Available
$ dmesg | grep tty
[ 0.000000] console [tty0] enabled
[ 3390.614686] cdc_acm 3-2:1.0: ttyACM0: USB ACM device
Update
I can force it to work under the following conditions:
01. Permissions for world must be set to rw ie:
sudo chmod 666 /dev/ttyACM0
02. Arduino IDE serial monitor needs to be open.
However these conditions are not sustainable as:
Permissions are reset each time the USB is connected.
The Arduino IDE serial monitor shouldn't need to be open.
The following fleshes out some of the ideas in the first answer (I tried to add this content to that answer and accept it, but the edits were rejected). I'm not an expert in the area, so please just use this information to support your own research.
You can do one of the following:
01. Alter the permissions on /dev/ttyACM0 so that world has read and write priviliges (something you may not want to do) - although you may find they reset each time the device is plugged in eg:
sudo chmod 666 /dev/ttyACM0
02. Create a rule in /etc/udev/rules.d that will set the permissions of the device (a restart will be required):
# navigate to rules.d directory
cd /etc/udev/rules.d
#create a new rule file
sudo touch my-newrule.rules
# open the file
sudo vim my-newrule.rules
# add the following
KERNEL=="ttyACM0", MODE="0666"
This also sets permissions for world to read and write, which you may not want to do.
For more information about this approach, see these answers:
https://unix.stackexchange.com/a/48596/92486
https://stackoverflow.com/a/11848003/1063287
03. The third option, which is the option I implemented, adds the Apache user to the dialout group so that if the script is being run by Apache, then it can access the device.
a) Find the location of your Apache config file, then search for the User setting within that file:
# open file in editor
sudo vim /etc/apache2/apache2.conf
# search for User setting
/User
You may find something like:
# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
b) Quit vim and search for APACHE_RUN_USER in /etc/apache2/envvars (if the above scenario applies):
# open file in editor
sudo vim /etc/apache2/envvars
# search for APACHE_RUN_USER
/APACHE_RUN_USER
You may find something like:
export APACHE_RUN_USER=www-data
c) Add the User www-data to the dialout group:
sudo usermod -a -G dialout www-data
d) Restart.
As the Apache user has been added to the dialout group, the script should now be able to access the device.
Further Reading
How to find the location of the Apache config file:
https://stackoverflow.com/a/12202042/1063287
The permissions on the file make no difference to the user that the program runs as
When you are logged in interactively you do have permission to use the /dev/ttyACM0
When your script is running (presumably as the apache user) it does not have permission
You need to alter the permissions on the /dev/ttyACM0
See the 2nd answer here How can I programmatically set permissions on my char device for an example of altering udev permissions so the file has the correct permissions
Based on the accepted answer, I was able to just add the following to my setup.sh script
printf "KERNEL==\"ttyACM0\", MODE=\"0666\"" | sudo tee /etc/udev/rules.d/si-ct.rules

WAMP is not running

I had installed WAMP in E: drive. I re-installed fresh copy of windows. Since then, WAMP only comes in red shade , not coming in green mode. Please help what should I do?
port 80 might be used by other services. test that using apache>services>test port 80. and disable that service.
When Windows is re-install or upgraded in-place, sometimes both the Apache and MySQL services are cleared out and the PATH environmental variable is reset.
Update the Path with the "bin" folders of Apache and MySQL.
Re-install the services...
If you are using WampDeveloper (I don't know which WAMP you are using), to install the services again it's (from the command line running as administrator):
Install Services:
httpd -k install -f "C:\WampDeveloper\Config\Apache\httpd.conf" -DSSL
mysqld --install Mysql --defaults-file="C:\WampDeveloper\Config\Mysql\my.ini"
The generic forms are:
Apache22\bin\httpd -k install
mysql5\bin\mysqld --install
If you are using Skpey exit and restart all service.
Tip:
on skype menu --> Tools --> Options --> advanced --> connection
Disable "Use port 80 and 443 as alternatives for incoming connections"