Posts mit dem Label linux werden angezeigt. Alle Posts anzeigen
Posts mit dem Label linux werden angezeigt. Alle Posts anzeigen

Mittwoch, 13. Juli 2022

Lösung: ping: socket: Operation not permitted. Kein ping als normaler Benutzer. Debian 10 buster.

Nach einem Update funktioniert ping nicht mehr als normaler Benutzer.

Anscheinend gab es eine Sicherheitslücke, welche gefixt werden musste.

 

Habe einen Standard Debian Kernel:

SMP Debian 4.19.249-2 (2022-06-30)

 

In diesem SUSE Supportartikel wird das Symptom beschrieben:

There are two components to be considered, file capabilities (cap_net_raw+eip)  and net.ipv4.ping_group_range kernel parameter.

 

Bei mir gab es keine Ausgabe für den Befehl

 root@pb:~# getcap /bin/ping

Die Ausgabe für

root@pb:~# sysctl net.ipv4.ping_group_range
net.ipv4.ping_group_range = 1    0

brachte den Grund hervor.

Man kann jetzt entweder den Bereich der Gruppennummern auf 1 bis 2147483647 setzen

oder 

mit setcap arbeiten.

Lösung 1:

root@pb:~# sysctl net.ipv4.ping_group_range="1 2147483647"
 

Lösung 2: 

root@pb:~# setcap cap_net_raw+eip /bin/ping
root@pb:~# getcap /bin/ping
/bin/ping = cap_net_raw+eip
 

Der Grund für die Änderung der ping Berechtigungen seitens Debian kommt wschl. wegen dieser CVE (Common Vulnerabilities and Exposures) 

CVE-2015-3636


Fazit:

Lösung 2 bevorzugen.


TODO:

Permanent machen von Lösung 2



Freitag, 2. April 2021

Softlinks in Linux auflösen mit readlink

Ein Softlink in Linux wird mit 

ln -s linkziel linkname

erzeugt.

Dabei darf ein Link auf einen Ordner, eine Datei oder einen anderen Link verweisen.

Durch Letzteres gibt es die Situation, dass man von einem Dateipfad nicht sicher sein kann, dass alle Pfadbestandteile wirklich existieren.

Nehmen wir einen lokalen Pfad a/b/c/datei.txt an.

Dann kann jedes Element darin ein Softlink sein.

Um den echten Pfad aufzulösen gibt es den Linux Befehl readlink.

Ohne Optionen gibt es nur das Endziel des Softlinks nach Auflösung jedes Bestandteils des Pfades aus.

 Mit Option -e müssen alle Bestandteile des Pfades aufgelöst werden können.

Es wird dann der um Softlinks bereinigte vollständige Dateipfad ausgegeben.

Mit Option -f darf der letzte Bestandteil des aufgelösten Dateipfades nicht vorhanden sein; d.h.

Aus a/b/c/datei.txt wird z.B. /d/e/f/g/h/zieldatei.txt.
Dann muss der Pfad /d/e/f/g/h/ existieren und zieldatei.txt darf fehlen im Dateisystem.

 

Mit Option -m werden alle Pfadbestandteile soweit wie möglich aufgelöst und wenn dies nicht möglich so belassen und mit dem Restpfad konkateniert.

 

Fazit:

Nur die Variante mit Option -e macht Sinn.

 

Nachfolgend ein Beispiellauf mit letztem Softlink "mehrpfadig":

 noname@pb:~/todel/linktest$ ls -l
total 4
drwxr-xr-x 3 noname noname 4096 Apr  2 15:44 a
lrwxrwxrwx 1 noname noname    6 Apr  2 15:17 start -> a/lElb
noname@pb:~/todel/linktest$ ls -l a
total 4
drwxr-xr-x 3 noname noname 4096 Apr  2 15:58 b
lrwxrwxrwx 1 noname noname    1 Apr  2 15:44 lEb -> b
lrwxrwxrwx 1 noname noname    3 Apr  2 15:10 lElb -> lEb
lrwxrwxrwx 1 noname noname    2 Apr  2 15:08 lNb2 -> b2
noname@pb:~/todel/linktest$ ls -l a/b
total 4
drwxr-xr-x 3 noname noname 4096 Apr  2 13:05 c
-rw-r--r-- 1 noname noname    0 Apr  2 15:24 fba
lrwxrwxrwx 1 noname noname    3 Apr  2 15:09 lEb -> lEb
lrwxrwxrwx 1 noname noname   18 Apr  2 15:58 lNexisting -> blabla/tests/gsddg
noname@pb:~/todel/linktest$ readlink start/lNexisting
blabla/tests/gsddg
noname@pb:~/todel/linktest$ readlink -e start/lNexisting
noname@pb:~/todel/linktest$ readlink -f start/lNexisting
noname@pb:~/todel/linktest$ readlink -m start/lNexisting
/home/noname/todel/linktest/a/b/blabla/tests/gsddg

   

 Beispiellauf mit letztem Link "einpfadig":

noname@pb:~/todel/linktest$ ln -snf blabla a/b/lNexisting
noname@pb:~/todel/linktest$ ls -l
total 4
drwxr-xr-x 3 noname noname 4096 Apr  2 15:44 a
lrwxrwxrwx 1 noname noname    6 Apr  2 15:17 start -> a/lElb
noname@pb:~/todel/linktest$ ls -l a 
total 4
drwxr-xr-x 3 noname noname 4096 Apr  2 16:17 b
lrwxrwxrwx 1 noname noname    1 Apr  2 15:44 lEb -> b
lrwxrwxrwx 1 noname noname    3 Apr  2 15:10 lElb -> lEb
lrwxrwxrwx 1 noname noname    2 Apr  2 15:08 lNb2 -> b2
noname@pb:~/todel/linktest$ ls -l a/b
total 4
drwxr-xr-x 3 noname noname 4096 Apr  2 13:05 c
-rw-r--r-- 1 noname noname    0 Apr  2 15:24 fba
lrwxrwxrwx 1 noname noname    3 Apr  2 15:09 lEb -> lEb
lrwxrwxrwx 1 noname noname    6 Apr  2 16:17 lNexisting -> blabla
noname@pb:~/todel/linktest$ readlink start/lNexisting
blabla
noname@pb:~/todel/linktest$ readlink -e start/lNexisting
noname@pb:~/todel/linktest$ readlink -f start/lNexisting
/home/noname/todel/linktest/a/b/blabla
noname@pb:~/todel/linktest$ readlink -m start/lNexisting
/home/noname/todel/linktest/a/b/blabla

 

Linux ls Kommando - Was bedeutet total ?

Wenn ein Verzeichnis mit dem Kommando ls -l aufgelistet wird, gibt es ja immer einen Vorspann der Art

noname@pb:~/todel/linktest$ ls -l a/b/c/d/e
total 24
drwxr-xr-x 2 noname noname       4096 Apr  2 13:29 f
drwxr-xr-x 2 noname noname       4096 Apr  2 13:25 f2
drwxr-xr-x 2 noname noname       4096 Apr  2 13:26 f3
drwxr-xr-x 2 noname noname       4096 Apr  2 13:28 f4
drwxr-xr-x 4 noname noname       4096 Apr  2 13:31 f5
-rw-r--r-- 1 noname noname 4194305024 Apr  2 13:52 fa
-rw-r--r-- 1 noname noname          0 Apr  2 13:28 fa2

Was bedeuet die Zahl 24?

Wie man bei GNU coreutils nachlesen kann, ist das die Summe aller direkten Einträge im aktuellen Ordner, dargestellt in der Standard Blockgröße 1024 Bytes ; Standard Blockgröße für die Kommandoausgabe (!=Dateisystemblockgröße).

Es wird hierbei der reale Platzverbrauch der Daten- und Verzeichnisdateien im Ordner berücksichtigt.

Verzeichnisdateien haben unabhängig von ihrem eigenen Inhalt nach ihrer Erzeugung eine konstante und fixe Größe von hier 4096 Bytes.

Die Datendateien können aber sogenannte Sparse Dateien sein, welche nominal größer sein können als ihr realer Plattenverbrauch im Dateisystem.

Man kann eine solche Sparse Datei z.B. mit dd erzeugen, was hier gemacht wurde:

noname@pb:~/todel/linktest$ dd if=/dev/zero of=a/b/c/d/e/fa bs=1k seek=4000k count=1
1+0 Datensätze ein
1+0 Datensätze aus
1024 bytes (1,0 kB, 1,0 KiB) copied, 0,000499488 s, 2,1 MB/s

Die reale Größe läßt sich hiermit anzeigen:

noname@pb:~/todel/linktest$ du -B 1 a/b/c/d/e/fa
4096    a/b/c/d/e/fa

Jetzt schauen wir uns nochmal die Auflistung des Ordners in Bytes an:

noname@pb:~/todel/linktest$ ls -l --block-size="1" a/b/c/d/e
total 24576
drwxr-xr-x 2 noname noname       4096 Apr  2 13:29 f
drwxr-xr-x 2 noname noname       4096 Apr  2 13:25 f2
drwxr-xr-x 2 noname noname       4096 Apr  2 13:26 f3
drwxr-xr-x 2 noname noname       4096 Apr  2 13:28 f4
drwxr-xr-x 4 noname noname       4096 Apr  2 13:31 f5
-rw-r--r-- 1 noname noname 4194305024 Apr  2 13:52 fa
-rw-r--r-- 1 noname noname          0 Apr  2 13:28 fa2

Der Ordner  a/b/c/d/e hat also in Summe seiner direkten Kinder:

realsize(f)+realsize(f2)+realsize(f3)+realsize(f4)+realsize(f5)+realsize(fa)+realsize(fa2)

 folgendes Ergebnis: 4096+4096+4096+4096+4096+4096+0 = 24576

noname@pb:~/todel/linktest$ echo $((4096*6))
24576

Ein nachträgliches befüllen von existierenden Unterordnern ändert nichts an dieser Summe!

Hier am Beispiel des Unterordners f vom betrachteten Ordner e.

Wie man hier sieht, ist der Ordner zu Anfang leer gewesen:

noname@pb:~/todel/linktest$ ls -l --block-size="1" a/b/c/d/e/f
total 0

Jetzt erzeugen wir eine Sparse Datei darin:

noname@pb:~/todel/linktest$ dd if=/dev/zero of=a/b/c/d/e/f/fa3 bs=1k seek=4000k count=1
1+0 Datensätze ein
1+0 Datensätze aus
1024 bytes (1,0 kB, 1,0 KiB) copied, 0,000475806 s, 2,2 MB/s
noname@pb:~/todel/linktest$ du -B 1 --apparent-size a/b/c/d/e/f/fa3
4194305024    a/b/c/d/e/f/fa3
noname@pb:~/todel/linktest$ du -B 1 a/b/c/d/e/f/fa3
4096    a/b/c/d/e/f/fa3
noname@pb:~/todel/linktest$ ls -l --block-size="1" a/b/c/d/e/f
total 4096
-rw-r--r-- 1 noname noname 4194305024 Apr  2 13:57 fa3
 

Die Ursprüngliche Ausgabe von ls für der Ordner e bleibt von dieser Änderung unberührt:

noname@pb:~/todel/linktest$ ls -l --block-size="1" a/b/c/d/e
total 24576
drwxr-xr-x 2 noname noname       4096 Apr  2 13:29 f
drwxr-xr-x 2 noname noname       4096 Apr  2 13:25 f2
drwxr-xr-x 2 noname noname       4096 Apr  2 13:26 f3
drwxr-xr-x 2 noname noname       4096 Apr  2 13:28 f4
drwxr-xr-x 4 noname noname       4096 Apr  2 13:31 f5
-rw-r--r-- 1 noname noname 4194305024 Apr  2 13:52 fa
-rw-r--r-- 1 noname noname          0 Apr  2 13:28 fa2

 

Dienstag, 1. Oktober 2019

Beispiel wie diff funktioniert

Beispiel wie diff -d funktioniert:

root@debianxc:~# cat gcc4.txt
float.h
iso646.h
limits.h
mf-runtime.h
ssp.h
stdio.h
string.h
unistd.h
stdarg.h
stdbool.h
stddef.h
stdfix.h
stdint-gcc.h
stdint.h
syslimits.h
unwind.h
varargs.h
root@debianxc:~# cat gcc6.txt
backtrace-supported.h
backtrace.h
float.h
iso646.h
omp.h
openacc.h
stdalign.h
stdarg.h
stdatomic.h
stdbool.h
stddef.h
stdfix.h
stdint-gcc.h
stdint.h
stdnoreturn.h
unwind.h
varargs.h
root@debianxc:~# diff -d gcc4.txt gcc6.txt #Zeige minimalstes ed Skript
0a1,2
> backtrace-supported.h
> backtrace.h
3,8c5,7
< limits.h
< mf-runtime.h
< ssp.h
< stdio.h
< string.h
< unistd.h
---
> omp.h
> openacc.h
> stdalign.h
9a9
> stdatomic.h
15c15
< syslimits.h
---
> stdnoreturn.h
root@debianxc:~#

Erklärungen:

1) Es werden ed Skripteditor Kommandos aufgelistet, mit denen aus der Datei 1 die Datei 2 wird.

2) Die Zeilen der Datei werden mit 1 zu zählen begonnen.

3) Die Änderungen sind nicht kontextbezogen, d.h. eine Änderung verändert nicht das Bezugsystem für nachfolgende Änderungsmitteilungen.

Wenn z.B. Datei 1 mit 0a1,10 eine Vorspan mit den ersten 10 Zeilen der Datei 2 erhält, dann sind die Zeilenbezüge für die folgenden diff Änderungsmitteilungen immer noch auf die Ausgangslage der Datei 1 bezogen und nicht etwa auf die um 10 Zeilen gewachsene Datei!

4) Es gibt die folgenden Operationen:
m(,n)d - löscht Zeile m (bis n) aus Datei 1

m(,n)cp(,q) - tauscht die Zeile m (bis n) von Datei 1 gegen die Zeile p (bis q) von Datei 2

map(,q) - fügt nach Zeile m von Datei 1 die Zeile p (bis q) an

5) Zeilennummer 0 kommt dann zum Einsatz, wenn man vor der ersten Zeile einen Append machen möchte.   

Linux firewall iptables at a glance

How iptables work


Before we begin, here is the meta-grammar for iptables:

ip tables
table   : filter (default) | nat | mangle | raw | security
filter  : INPUT | FORWARD | OUTPUT
nat     : PREROUTING | OUTPUT | POSTROUTING
mangle  : INPUT | FORWARD | PREROUTING | OUTPUT | POSTROUTING
table   : {chain}+
chain   : {userdefined} | {built-in}
built-in: INPUT | FORWARD | OUTPUT | PREROUTING | POSTROUTING
chain   : {rule}+ 
rule    : {criteria}+ -> {chain | target}
target  : ACCEPT, DROP, QUEUE or RETURN

As you can see, there is the concept of tables. These tables classify the purpose of their containing set of rule chains. All rule chains in table filter have therefore a filter purpose in charge.
Let's explain the firewall processing of IP Packets with an example.
An application on our host generates content to be sent outside via network. Because this is content originating from ourselves, the OUTPUT chain of rules is going to be applied. But this pre-named OUTPUT chain exist in multiple tables in seperate instances. As you can see, the tables filter, nat and mangle all have their own instance of an OUTPUT chain. There is a predefined order between these OUTPUT chains from different tables. Lets say that first the filter.OUTPUT is being processed followed by nat.OUTPUT and finalized by mangle.OUTPUT. Each element in e.g. filter.OUTPUT is a rule, which can terminate with an end status (ACCEPT,DROP,...) or link to another rule in a chain of the current table. If no rule of the running chain has to be processed anymore within the current table, then the next table's chain of the same type is becoming running.
Long story short: Packets get processed by first checking their orginating source and target ip and based on that the appropiate chain gets selected. Multiple instances of this chain can be located in multiple tables. Each of this chain instances will be processed one by one. So the first chain instance must be finished before the next instance can start.
We also must consider that not every chain getting processed has multiple instances in each table.
After one set of chains with the same type (name) is finished, any remaing type of chains suitable for the network traffic gets a run.
.....
An here comes a dump:

[root@localhost ~]# iptables -t filter -L INPUT
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
ACCEPT     all  --  anywhere             anywhere
INPUT_direct  all  --  anywhere             anywhere
INPUT_ZONES  all  --  anywhere             anywhere
ACCEPT     icmp --  anywhere             anywhere
REJECT     all  --  anywhere             anywhere             reject-with icmp-host-prohibited

[root@localhost ~]# iptables -t filter -S INPUT
-P INPUT ACCEPT
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -j INPUT_direct
-A INPUT -j INPUT_ZONES
-A INPUT -p icmp -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
[root@localhost ~]# man iptables
[root@localhost ~]# iptables -I INPUT -s 192.168.1.0/24 -j ACCEPT
[root@localhost ~]# iptables -t filter -S INPUT
-P INPUT ACCEPT
-A INPUT -s 192.168.1.0/24 -j ACCEPT
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -j INPUT_direct
-A INPUT -j INPUT_ZONES
-A INPUT -p icmp -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited 

Regular Expressions in find bash shell sed grep with examples

find '*.txt'
    metas * bel. lang, matched alles inkl. Leerstring, inkl . , / usw.
          ? genau ein Zeichen lang inkl . , / usw.
    metas beziehen sich nicht auf vorhergehenden Regexp!   
root@osboxes:/var/lib/typo3s/atypo3# find -maxdepth 0 -name '*'
.
root@osboxes:/var/lib/typo3s/atypo3# find -maxdepth 1 -name '*'
.
./uploads
./.htaccess
   
Bash Shell:
meta * beliebig lang, passt auf alles, was nicht mit . beginnt.
        Bezieht sich nicht auf einen vorangegangenen Regexp.
meta ? ein Zeichen lang, passt auf alles außer /
     ? passt auf ., wenn das ? nicht das erste Musterzeichen ist
     ? wird literal interpretiert, wenn es als Muster keinen Treffer macht !!!

root@osboxes:/# echo *
bin boot dev etc home initrd.img initrd.img.old lib lost+found media mnt opt proc root run sbin srv sys tmp usr var vmlinuz vmlinuz.old
root@osboxes:/# echo *.
*.
root@osboxes:/# echo .*
. .. .cache

root@osboxes:/# echo ?
?
root@osboxes:/# echo ??
??
root@osboxes:/# echo ?.
?.
root@osboxes:/# echo .?
..
root@osboxes:/# echo ???
bin dev etc lib mnt opt run srv sys tmp usr var
root@osboxes:/# echo ???/
bin/ dev/ etc/ lib/ mnt/ opt/ run/ srv/ sys/ tmp/ usr/ var/
root@osboxes:/# ls
bin   etc         initrd.img.old  media  proc  sbin  tmp  vmlinuz
boot  home        lib             mnt    root  srv   usr  vmlinuz.old
dev   initrd.img  lost+found      opt    run   sys   var
root@osboxes:/# ls opt/
eclipse  VBoxGuestAdditions-5.2.26  wildfly  wildfly-12.0.0.Final
root@osboxes:/# echo ???????????
vmlinuz.old
root@osboxes:~# echo *
Desktop dnsstart.sh Documents Downloads history20180323_1811Uhr.txt history20190406_1621.txt Music mydumpscript.sh Pictures Public Templates Videos Xauthority
root@osboxes:~# echo */*
Downloads/eclipse-jee-oxygen-3-linux-gtk.tar.gz Downloads/wildfly-12.0.0.Final.tar.gz
root@osboxes:~# echo */.*
Desktop/. Desktop/.. Documents/. Documents/.. Downloads/. Downloads/.. Music/. Music/.. Pictures/. Pictures/.. Public/. Public/.. Templates/. Templates/.. Videos/. Videos/..
root@osboxes:~# echo .*
. .. .bash_history .bashrc .cache .config .dbus .gnupg .ICEauthority .lesshst .local .mozilla .mysql_history .nano .profile .wget-hsts
root@osboxes:~# echo .?*
.. .bash_history .bashrc .cache .config .dbus .gnupg .ICEauthority .lesshst .local .mozilla .mysql_history .nano .profile .wget-hsts
--------------------------------------------------------------------------------

Beispiel:
grep -G: 'abc\|ABC' , '^Anfang\\...\?E$' matches 'Anfang\12E' und 'Anfang\12TE'
grep -E: 'abc|ABC'  , '^Anfang\\...?E$' matches 'Anfang\12E' und 'Anfang\12TE'
grep -P: 'abc|ABC'  , '^Anfang\\...?E$' matches 'Anfang\12E' und 'Anfang\12TE'

-------------------------------------------------------------------
sed:
-E, --regexp-extended, -r : use ext. reg exp like in grep -E

                    . matched auch "\n"
             metas = ^, $, \, ., *   
    Extended metas += ?, +, {, }, (, ), |
    Prios: () > \digit > Repeats >  = \Char > Concat > ^,$ > |
    \n = Newline
    \digit = n-th Bracket expression
    \Char = with char one of { $, *, ., [, \, or ^}
    In Subsitution part of s/search-pat/subst-pat/
    the '&' stands for the whole matched string.
    \digit References can occur in both search-pat and subst-pat in \digit notation. This is different to perl where \digit <-> $digit in search <->subst.
   
Beispiel:
sed normal: '^Das ist  *ein Satz\.\nDer \+naechste Satz\.$'
sed -E    : '^Das ist  *ein Satz\.\nDer +naechste Satz\.$'
sed 'abc*defghi\+jkl' matched auf 'abdefghijkl' und 'abccccdefghiijkl'
sed '\(abc\)*xyz\1\{2\}' matched auf 'abcxyzabcabc' und 'abcabcxyzabcabc'
    !!! nicht aber auf 'xyzabcabc' !!!
root@osboxes:~# sed -n '/\(abc\)*xyz\1\{2\}/p' <xyz
xyzabcabc
abcxyz
abcxyzabc
abcxyzabcabc
abcabcabcabcxyzabcabc
E
abcxyzabcabc
abcabcabcabcxyzabcabc

root@osboxes:~# sed -n '/\(abc\)xyz\1\+7/p' <abcxyzabcabcabc7
abcxyz17
abcxyz117
abcxyzabc7
E
abcxyzabcabcabc7
abcxyzabc7

-------------------------------------------------------------------

grep:
Basic -G default
Extended -E more Metas
Perl -P Perlregexp
    Basic metas     = ^, $, \, ., *
    Extended metas += ?, +, |, {, (, ) # Es wird nicht } mitaufgezählt!!! Testen
    Prios: Repet > Concat > Alternation
    Die Repetitions beziehen sich auf den unmittelbar vorangehenden Regexp
    Repetitions = 
       ?      The preceding item is optional and matched at most once.
       *      The preceding item will be matched zero or more times.
       +      The preceding item will be matched one or more times.
       {n}    The preceding item is matched exactly n times.
       {n,}   The preceding item is matched n or more times.
       {,m}   The preceding item is matched at most m times.  This  is  a  GNU
              extension.
       {n,m}  The  preceding  item  is  matched at least n times, but not more
              than m times.

-------Standard grep restriction-----------------------------------------
https://www.gnu.org/software/grep/manual/grep.html#Regular-Expressions
How can I match across lines?
Standard grep cannot do this, as it is fundamentally line-based. Therefore, merely using the [:space:] character class does not match newlines in the way you might expect.

With the GNU grep option -z (--null-data), each input and output “line” is null-terminated; see Other Options. Thus, you can match newlines in the input, but typically if there is a match the entire input is output, so this usage is often combined with output-suppressing options like -q, e.g.:

printf 'foo\nbar\n' | grep -z -q 'foo[[:space:]]\+bar'
If this does not suffice, you can transform the input before giving it to grep, or turn to awk, sed, perl, or many other utilities that are designed to operate across lines.

--------grep -P supports multiline search -------------------------------------
Inspired by https://unix.stackexchange.com/questions/112132/how-can-i-grep-patterns-across-multiple-lines:
Simply a normal grep which supports Perl-regexp parameter P will do this job.

$ echo 'abc blah
blah blah
def blah
blah blah' | grep -oPz  '(?s)abc.*?def'
abc blah
blah blah
def
(?s) called DOTALL modifier which makes dot in your regex to match not only the characters but also the line breaks.

root@osboxes:/var/lib/typo3s/atypo3# find fileadmin/ -name '*.ts' ! -name '*_ori*' -print0 |  xargs -0n1 grep -PHoz  '\bpage\b *= *\bPAGE\b *\n *\bpage\b *\{ *\n?'
fileadmin/templates/mobile/ts/setup.main.ts:page = PAGE
page {
root@osboxes:/var/lib/typo3s/atypo3#

-o: only the matching part of the line will be outputted. Otherwise the match would be shown as the whole file, because each file is treadet as one long line and seperate files are divided by the Null Character.