Skip to content

u/Street-Guard

In this archive from Feb 2020 to Jan 2024

1
posts
35
comments
0
media
59
score

It's not true that no MAC programs are officially supported in Arch.

AppArmor is supported by the Arch kernels and the apparmor package is in the official repos. It's not enabled by default and the apparmor package is not installed by default - but that's easy to do. In any case, AppArmor is officially supported.

SELinux is supported in the Arch kernels as well. But as mentioned in other posts here, many core utilities and systemd must be rebuilt in order to use it. They can be installed in various ways.

Tomoyo is also available for Arch. Depending on which version you use the userland programs are available in the AUR.

5 points

Jelle, I'm surprised that you say that AA is "more or less supported". IMO, Arch does support AA completely. It uses what upstream offers. Yes, if you install some applications (like Firefox or LibreOffice) in Ubuntu, it also automatically installs the proper AA profiles - which are not included in the official upstream package. So if they are not available in Arch this is not because AA is "more or less supported".

3 points

This is how I do it. I'm using the following script called updatecheck:

#!/bin/bash

checkupdates > /tmp/updates.txt \
&& (grep -E 'linux*|amd-ucode|intel-ucode|btrfs-progs|cryptsetup|nvidia*|mesa|systemd*|*wayland*|xf86-video-*|xorg-server*|xorg-fonts*' /tmp/updates.txt && printf "\nReboot recommended!" >> /tmp/updates.txt)

if [ -s /tmp/updates.txt ]

then
     notify-send --urgency=critical \
	 --icon=/usr/share/icons/Papirus-Dark/48x48/apps/mx-updater.svg \
	 "Updates available:" "$(cat /tmp/updates.txt)"
	 
fi


FILE="/tmp/aurupdates.txt"

yes N | paru -Sua > "$FILE"

STRING="there is nothing to do"

if ! grep -q "$STRING" "$FILE" 

then 
   
   notify-send --urgency=critical \
	--icon=/usr/share/icons/Papirus-Dark/48x48/apps/mx-updater.svg \
	"AUR-Updates available:" "$(cat /tmp/aurupdates.txt)"
            
fi

Then create the following user unit updatecheck.service:

[Unit]
Description=Check for updates
Wants=network-online.target
After=network-online.target

[Service]
ExecStart=/home/user/bin/updatecheck

[Install]
WantedBy=multi-user.target

and the corresponding updatecheck.timer:

[Unit]
Description=Check for updates

[Timer]
OnBootSec=20min
OnUnitActiveSec=60min

[Install]
WantedBy=timers.target

and enable it with

systemctl --user enable updatecheck.timer
1 points

Could you be more specific? As a matter of fact I‘m using Firejail. In order to make sure it isn‘t the culprit I explicitly executed ˋ/usr/bin/makepkg -sˋ to bypass Firejail. But that didn’t change anything, and I didn’t see anything related in journalctl. Perhaps I missed something?

0 points

I've created the following script in which I try to implement what is said on https://wiki.archlinux.org/title/System_maintenance

#!/bin/bash

UPDATE1(){
        sudo reflector --verbose --country Germany --country France --country Czechia --country Denmark --country Sweden --country Netherlands     --country Switzerland --protocol https --latest 20 --score 10 --sort age --ipv4 --save /etc/pacman.d/mirrorlist
        
        sudo pacman -Syu
        paru -Sua
                
        echo
        
        # https://wiki.archlinux.org/title/Pacman/Pacnew_and_Pacsave#Locating_.pac*_files :
        sudo updatedb && locate --existing --regex "\.pac(new|save)$" > ~/pacnew.log
        
        # https://wiki.archlinux.org/title/Pacman#Cleaning_the_package_cache :
        sudo paccache -ruk0 && sudo paccache -rvk2 
        
        # https://wiki.archlinux.org/title/Pacman/Tips_and_tricks#Listing_packages :
        pacman -Qqn > pkglist.txt
        pacman -Qqm > pkglist-foreign.txt
                
        echo
        
                       
      if [ -s ~/pacnew.log ]

      then
      
      echo

          echo "ATTENTION! .pacnew and/or .pacsave files available:"
          
          cat ~/pacnew.log
          
          echo
          
          # https://wiki.archlinux.org/title/Users_and_groups#Group_management
          # Warning: Arch Linux defaults of the files are created as .pacnew files by new releases of the filesystem package. 
          # Unless Pacman outputs related messages for action, these .pacnew files can, and should, be disregarded/removed.
          FILE1=/etc/group.pacnew
          FILE2=/etc/shadow.pacnew
          FILE3=/etc/gshadow.pacnew
          FILE4=/etc/passwd.pacnew
       if [ -f "$FILE1" ]; then
        echo -e "\033[0;31m*** ATTENTION: The file \033[0;32m$FILE1 \033[0;31mexists. Do NOT merge!!!***\033[0m"
       fi
       if [ -f "$FILE2" ]; then
        echo -e "\033[0;31m*** ATTENTION: The file \033[0;32m$FILE2 \033[0;31mexists. Do NOT merge!!!***\033[0m"
       fi
       if [ -f "$FILE3" ]; then
        echo -e "\033[0;31m*** ATTENTION: The file \033[0;32m$FILE3 \033[0;31mexists. Do NOT merge!!!***\033[0m"
       fi
       if [ -f "$FILE4" ]; then
        echo -e "\033[0;31m*** ATTENTION: The file \033[0;32m$FILE4 \033[0;31mexists. Do NOT merge!!!***\033[0m"
       fi
       
       
      fi
      
      echo
      
      # https://wiki.archlinux.org/title/System_maintenance#Restart_or_reboot_after_upgrades
      sudo mycheckservices -u
      
      echo
      
      # Check for services to be restarted
      sudo longoverdue list > /tmp/serviceupdates.txt
                
      if [ -s /tmp/serviceupdates.txt ]; then
        cat /tmp/serviceupdates.txt
        echo
        echo "*** Execute 'servrestart' *** "
      fi
            
     }

# check for news on https://archlinux.org/      
FILE="/tmp/news.txt"
paru -Pw 2>&1 | tee "$FILE"
STRING="no new news" 

 if ! grep -q "$STRING" "$FILE"; then
    read -n 1 -p "Continue? [Any key/N(o)]" ANSWER
    
  if [ "$ANSWER" == "N" ]
    then
    
    echo
    echo "  *** Aborted ***"
  else
   
   echo
    echo "Update continued"
    
    UPDATE1
    
  fi
  
  else
   
   UPDATE1
   
fi

Note that mycheckservicesis actually checkservicesfrom pacman-contrib (which also executes pacdiff if necessary) with line 99 modified to

    systemctl --no-legend --full --type service --state running | tr -d '●' | awk '{print $1}' | sed 's/systemd-logind.service\|sddm.service\|plasma-kwin_wayland.service//g' | sed '/^$/d'

This makes sure that those services are not automatically restarted as this would log me out closing all open applications This is not what I want.

longoverdueis the respective AUR package which I've added as checkservices doesn't catch all services nor user units. Lines 11 -15 look like this:

# List of services not to restart automatically
NO_AUTORESTART = {"dbus.service": "reboot required",
        "systemd-logind.service": "will log all users out",
        "sddm.service": "will log all users out",
        "plasma-kwin_wayland.service": "user unit - will log all users out"}

servrestartis simply the following alias:

alias servrestart="sudo longoverdue restart && longoverdue restart"
2 points

Also, found a reddit thread that suggested firejail might not be as safe.

That's not justified, IMO. Firejail had its vulnerabilities like many other packages but they were fixed very fast. And if it comes to Firejail being a SUID program, there are ways to mitigate this risk.

Regarding AppArmor: Read the article in the Arch Linux wiki and then the man pages, particularly https://man.archlinux.org/man/extra/apparmor/apparmor.d.5.en, https://man.archlinux.org/man/extra/apparmor/aa-logprof.8.en and https://man.archlinux.org/man/extra/apparmor/aa-autodep.8.en. A good source is also https://documentation.suse.com/sles/12-SP4/html/SLES-all/part-apparmor.html

1 points

FWIW, I'm using a very simple update notification script (without an online check):

#!/bin/bash

checkupdates > /tmp/updates.txt

if [ -s /tmp/updates.txt ]

then

	 zenity --warning --width=500 --height=1000 --title="Updates available" --text " $(cat /tmp/updates.txt)"

fi


FILE="/tmp/aurupdates.txt"

yes N | paru -Sua > $FILE

STRING="there is nothing to do"

if ! grep -q "$STRING" "$FILE" 

then 
   
   zenity --warning --width=500 --height=500 --title="AUR-Updates available" --text " $(cat /tmp/aurupdates.txt)"
         
fi
1 points

I was looking at firejail. It supports appamour. I am not sure which one is better.

See here. One advantage of Firejail is that it comes with profiles for many applications while there are only few ready-to-use profiles in AppArmor. However, it is relatively easy to write own profiles in AppArmor.

You should read https://wiki.archlinux.org/title/Firejail#Enable_AppArmor_support and https://wiki.archlinux.org/title/AppArmor

1 points

Actually everything is explained on the Arch wiki Firejail page.

  1. whitelist directives for your /home doesn't make sense for evince as that means that everything is blocked what is not explicitly whitelisted.
  2. The noblacklist directive must be added above the blacklist and/or .inc lines. The best way how to do this: Create evince.local in ~/.config/firejail and add the noblacklist directive therein. Please remember that editing the profiles in /etc/firejail directly is not recommended as they will be overwritten with every update.
2 points

Should there be a , between bpf and loglevel=3 quiet and one comma after quiet, to seperate the crypt?

loglevel=3 quiet was the standard value, should every kernel paramater be seperated by a comma?

No, they should be separated by a space.

Regarding your other questions: There is no need to bother. AppArmor is supported by all official Arch kernels. Just set it up as explained in the wiki. That's how I did it and it works as it should.

3 points

That's true. But let's face it: it makes a big difference with whom you get into as a user. You and your fellow forum moderators are doing a great job! But I remember a time when there was a (meanwhile retired) moderator (I won't mention his name) whose biggest hobby seemed to be to shoo away as many users as possible, quite often with a rude language at the edge of insulting. I think that behavior contributed a lot to the mixed reputation of the Arch community.

Fortunately, this has changed to the better since then. The discussion style has become more moderate and functional. Thanks a lot to you and your collegues and to helpful forum members like loqs and seth!

1 points

Well, I always do it. And it's easy if you create a small update script which contains something like:

sudo updatedb && locate --existing --regex '\.pac(new|save)$' > pacnew.log
if [ -s pacnew.log ]

  then
  
  echo

  echo "ATTENTION! .pacnew and/or .pacsave files available":
  
  cat pacnew.log

  fi    

Then you can simply execute pacdiff:

alias pacdiff='sudo -H DIFFPROG=meld pacdiff'
1 points

Thanks for your comprehensive reply! However, I still have some questions.

Learning mode can't do much more than list what it would have blocked within the context of the current policies. ... The thousands of rules are the reason I mentioned that learning mode is the most effective with an already provided set of abstractions,

I don't understand that. What do you mean by "within the context of the current policies" and "provided set of abstractions"? I couldn't find any pre-defined abstractions so I'm not sure how the rules created by the learning mode could be limited somehow. What am I missing?

That being said, I wonder if it would make sense to install AppArmor or, even better yet, Firejail (which comes with profiles for many applications) first and Tomoyo thereafter. Since most applications would already be confined by those profiles, Tomoyo learning would not create rules for actions already blocked by Firejail. This would greatly reduce the number of rules in learning mode to be sifted through. Does this make sense to you?

1 points

Aside from using (and possibly finetune) the profiles in /usr/share/apparmor/extra-profilesthere are, e.g., many github repositories which offer self-made AppArmor profiles. The question is always how good they are, though.

But it's always possible and relatively easy to create your own profiles with aa-autodepand aa-logprof.

1 points

I've been testing Tomoyo in Arch running in a VM for some days and can confirm that it works together with AppArmor.

However, I still have problems to get along with it. Yes, there is a learning mode which is fine. However, when is it time to stop learning mode? After one day or after one week? In AppArmor a profile is created for a specific application which is easy to read (and to check with aa-logprof). In Tomoyo thousands of rules are created for the whole system. It's impossible to check all of them, hence, it's impossible to see if it includes rules which are possibly too permissive, IMO.

Do you have any suggestions?

1 points

There are many extra profiles in /usr/share/apparmor/extra-profileswhich are (according to the README therein)

not turned on by default because they are not as mature as the profiles in /etc/apparmor.d/.

Nevertheless you can use them - but further finetuning is probably necessary. E.g., there is a profile usr.lib.firefox.firefox. Copy that to /etc/apparmor.d and set it to complain mode:

sudo aa-complain *.firefox

Start Firefox and leave the profile in complain mode for some time while frequently executing sudo aa-logprofin order to add more needed rules. Once aa-logprof remains quiet you can set the profile to enforce mode with aa-enforce.

2 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.