Snap-confine has elevated permissions and is not confined but should be. Is there a permanent fix? - linux

lately I've been getting an error for some applications. They are not working as normally before. I think some system update caused this issue. I'm using ubuntu 22.04.
I've already check this: Snap-confine has elevated permissions and is not confined but should be. Refusing to continue to avoid permission escalation attacks
and Diego V's answer is working for me. However, it only works until system reboot, after system restart the problem is re-occurring, and I have to do the fix (with the cmds) every time after reboot. Is there a permanent fix for this problem ?

I was having the exact same issue (also on Ubuntu 22.04) and found that apparmor was inactive:
$ systemctl status apparmor
I enabled apparmor:
$ sudo systemctl enable apparmor
which starts appormor at boot (it does not start it in the current session: sudo systemctl start apparmor).
https://www.linuxcapable.com/how-to-enable-disable-apparmor-on-ubuntu-22-04-lts

I don't have rights to comment so I can only reply here that it remains an issu and like Null I seek an answer other than provided by Diego V, which works until reboot where apparmor is already enabled/running so doesn't require trekerj's answer.

Related

Centos7 unable to run #reboot command

I am not able to run reboot commands on my CentOS 7 machine.
For example I've created a script: /home/usr/myscript.sh (marked executable) with:
echo "hello world" > example.txt
When Im trying to run the script from terminal everything works good.
I tried to start the script on reboot at the end of the file:
nano /etc/crontab
I added:
#reboot /home/usr/myscript.sh
and on restart, nothing happen.
I also tried to edit file:
crontab -e
its looks like a new generated file, I've typed my command, and again nothing happend.
How can I run a command on CentOS at reboot?
I tried to insert that command on my Ubuntu machine, and everything was good and worked properly.
Anyone can advise on different way (maybe 3rd party program) that will help me to manage the reboot jobs?
Thanks for the help.
BTW, its might be duplicate, but I cant find any answer that helped me
In CentOS/RHEL 7, the systemctl utility replaces some older power management commands used in previous versions. The table below compares the older and new equivalent systemctl commands. The old commands listed in the table still exist for compatibility reasons.
Older Command systemctl equivalent Description
halt systemctl halt Halts the system
poweroff systemctl poweroff Powers off the system
reboot systemctl reboot Restarts the system
pm-suspend systemctl suspend Suspends the system
pm-hibernate systemctl hibernate Hibernates the system
pm-suspend-hybrid systemctl hybrid-sleep Hibernates and suspends the system
I was able to reach this out by adding a crontab file for my user.
with the following command:
crontab -u usrname filename
That allow me to run my scripts.
Thanks !

Is there a way to 'store' Sudo temporarily

I'm quite new to Linux. I remember using a tutorial were you were able to declare your sudo (+password) at the start and then use terminal without having to do sudo or import your password again.
I.e.
Sudo yum-get update -> yum-get update.
Sorry if this is a very obvious question, I honestly don't remember where the tutorial was from, and how to do it again.
ps - if it helps, I'm on a RedHat Distro, but go between Debian and RedHat.
You can use su. This way you are changing the ownership of the session to root (by default, you can also change to any other user on the system) and therefore you will be able to avoid the sudo.
Here you can find some more information on the command.
You may use
sudo -i
It acquires the root user's environment and kind of simulates a login into the root account

Linux CentOS 7 autofs does not mount network share after reboot

Problem:
I have CentOS 7 Linux VM with cifs installed. I added a mount point using autofs where the whole idea was to automatically mount a network share every time VM boots. However, when I run this command:
ls /mnt/vmshare/trinity
I get
ls: cannot access /mnt/vmshare/trinity: No such file or directory
Workaround:
What I'm having to do is run this command after each reboot
/sbin/service autofs start
Then I can see the files in trinity.
Maybe autofs does not even start by default on reboot. How to make sure autofs starts on reboot? Or in general, how to solve my problem above?
Thanks so much!
for CentOS 7:
systemctl enable autofs
check with:
systemctl is-enabled autofs
I don't recall exactly what I used to figure this one out, but maybe it will get you on the right track.
I did some research on this a few years ago, and I believe the term you're looking for is "persistent mount."
You'll need to create or find the local mount point for your network directory. For instance, in mine.. /media/disco/disknamehere.../.../Share
This must be added to /etc/fstab with the correct options in place. Sorry I couldn't be more help.
Try to run
chkconfig autofs on
that will enable autofs service to start on boot.

Fail2Ban Will Not Start

I am running Centos 6.5 (Kernel Linux jspring 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux) and I was wondering if someone could assist - Im installing Fail2Ban through yum however when I go to run it I am getting the following error;
service fail2ban start
Starting fail2ban: ERROR Directory /var/run/fail2ban exists but not accessible for writing
[FAILED]
If anyone could advise me how to fix this that would be great.
Thanks!
There are several things that could be causing this.
First make sure the permissions and ownership are correct as the other answers state. The directory permissions should be drwxr-xr-x (a.k.a. 644) and it should be owned by root:root.
Now make sure you are attempting to run the start command with the proper authority. If service fail2ban start does not work, try sudo service fail2ban start. Using sudo is recommended but you could also switch to or login as the root user.
You may also want to reboot after you get it running and then run sudo service fail2ban status to make sure it successfully started up again.
You need to set the appropriate rights on the mentioned directory:
drwxr-xr-x root:root
You should set the permissions like this: chmod -R 644 /var/run/fail2ban/
As people have mentioned, this is clearly a permissions issue. I'm not sure if this applies to your version but fail2ban in 2018 has a client, run as:
sudo fail2ban-client start
(or restart or status). It must be run as sudo though.
As is documented in the official commands list here the command fail2ban start <jail> is clearly used to start jails and not to start fail2ban. So you completely missunderstood it's usage.
Try to first stop and then quickly start again the jail sshd that is enabled by default:
fail2ban-client stop sshd
fail2ban-client start sshd
Hey! It works!

Why running sudo to my own account fixes graphical problems in Swing GUI

My swing GUI application starts with a script.
When I run that script under Linux without sudo it gives me unexpected Look and feel and other graphical problems.
Why is running with sudo su to my own account fixes this problem?
One might guess that the program is trying to make use of a file that has permissions that allow root to access it, but not your uid. Perhaps you have a library installed with wrong permissions?
strace will tell you what files your app is trying to access.

Resources