Skip to contentSkip to conversation

98syslog: try to dynamically check for rsyslog moddir

PATCH In review Andrey Borzenkov 4 participants 7 messages Sep 10, 2010 4 messages not in the archive

lore
Share & tools
lore
#0 lore raw
Quoted 57 lines · On Friday 10 of September 2010 15:48:22 Harald Hoyer wrote:
Quoted 56 lines · Tomasz Paweł Gajc

Dnia 2010-09-08, o godz. 18:52:13

Andrey Borzenkov<arvidjaar-JGs/[email protected]> napisał(a):

Quoted 53 lines

Thomas pointed out that default module path may not be correct (Mandriva installs modules under architecture dependent path). Unfortunately rsyslog does not seem to offer any way to query for
default configuration values. Here is rather hack - try to load non-existing module and fetch path from error message.

Example of error message from version 4.6.4:

rsyslogd: could not load module '/lib64/rsyslog/_No_sUcH_MOduLe.so', dlopen:
/lib64/rsyslog/_No_sUcH_MOduLe.so: cannot open shared object
file: No such file or directory

---

  modules.d/98syslog/install |   17 ++++++++++++++++-
  1 files changed, 16 insertions(+), 1 deletions(-)
(quoted diff) +0 -0

b/modules.d/98syslog/install index 1fd1b6f..e3d02bf 100755

modules.d/98syslog/install +0 -1
@@ -1,6 +1,21 @@
 
  #!/bin/sh
  if type -P rsyslogd>/dev/null; then
 
-

installs="rsyslogd /lib/rsyslog/lmnet.so /lib/rsyslog/imklog.so
/lib/rsyslog/imuxsock.so" + # module path can be changed during
build and currently rsyslog

modules.d/98syslog/install +1 -0
+	# does not provide any means to query for it. Use hack - try

to

modules.d/98syslog/install +8 -0
+	# load non-existent module and look at error message
+	R_CONF=/tmp/dracut.rsyslog.conf.$$
+	R_ERR=/tmp/dracut.rsyslog.err.$$
+	R_MODDIR=
+	echo '$ModLoad _No_sUcH_MOduLe'>  $R_CONF
+	if [ -s $R_CONF ]; then
+		rsyslogd -N 1 -f $R_CONF 2>  $R_ERR>  /dev/null
+		R_MODDIR=$(grep ' could not load

module .*_No_sUcH_MOduLe' $R_ERR)

modules.d/98syslog/install +6 -0
+		R_MODDIR=${R_MODDIR#*could not load module \'}
+		R_MODDIR=${R_MODDIR%\', *}
+		R_MODDIR=${R_MODDIR%/*}
+	fi
+	[ -n "$R_MODDIR" ] || R_MODDIR=/lib/rsyslog
+	installs="rsyslogd $R_MODDIR/lmnet.so $R_MODDIR/imklog.so

$R_MODDIR/imuxsock.so" elif type -P syslogd>/dev/null; then

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

installs="syslogd"

elif type -P syslog-ng>/dev/null; then

Indeed this patch is more precise than my simplified one ;)

ugly hack :-/ plus you want mktemp to prevent attacks..

Just to make sure - it was NAK? :)

A message that is not in the archive (sent off-list or not yet received): E1Ou4kw-0005pA-00.arvidjaar-mail-ru-eJLJSXF0gEtsdVUOrk1QfQ@public.gmane.org

#2 lore raw
Quoted 60 lines · Andrey Borzenkov
Quoted 59 lines · On Friday 10 of September 2010 15:48:22 Harald Hoyer wrote:
Quoted 58 lines · Tomasz Pawe³ Gajc

Dnia 2010-09-08, o godz. 18:52:13

Andrey Borzenkov<arvidjaar-JGs/[email protected]> napisa³(a):

Quoted 55 lines

Thomas pointed out that default module path may not be correct (Mandriva installs modules under architecture dependent path). Unfortunately rsyslog does not seem to offer any way to query for
default configuration values. Here is rather hack - try to load non-existing module and fetch path from error message.

Example of error message from version 4.6.4:

rsyslogd: could not load module '/lib64/rsyslog/_No_sUcH_MOduLe.so', dlopen:
/lib64/rsyslog/_No_sUcH_MOduLe.so: cannot open shared object
file: No such file or directory

---

   modules.d/98syslog/install |   17 ++++++++++++++++-
   1 files changed, 16 insertions(+), 1 deletions(-)
(quoted diff) +0 -0

b/modules.d/98syslog/install index 1fd1b6f..e3d02bf 100755

modules.d/98syslog/install +0 -1
@@ -1,6 +1,21 @@
 
   #!/bin/sh
   if type -P rsyslogd>/dev/null; then
 
-

installs="rsyslogd /lib/rsyslog/lmnet.so /lib/rsyslog/imklog.so
/lib/rsyslog/imuxsock.so" + # module path can be changed during
build and currently rsyslog

modules.d/98syslog/install +1 -0
+	# does not provide any means to query for it. Use hack - try

to

modules.d/98syslog/install +8 -0
+	# load non-existent module and look at error message
+	R_CONF=/tmp/dracut.rsyslog.conf.$$
+	R_ERR=/tmp/dracut.rsyslog.err.$$
+	R_MODDIR=
+	echo '$ModLoad _No_sUcH_MOduLe'>   $R_CONF
+	if [ -s $R_CONF ]; then
+		rsyslogd -N 1 -f $R_CONF 2>   $R_ERR>   /dev/null
+		R_MODDIR=$(grep ' could not load

module .*_No_sUcH_MOduLe' $R_ERR)

modules.d/98syslog/install +6 -0
+		R_MODDIR=${R_MODDIR#*could not load module \'}
+		R_MODDIR=${R_MODDIR%\', *}
+		R_MODDIR=${R_MODDIR%/*}
+	fi
+	[ -n "$R_MODDIR" ] || R_MODDIR=/lib/rsyslog
+	installs="rsyslogd $R_MODDIR/lmnet.so $R_MODDIR/imklog.so

$R_MODDIR/imuxsock.so" elif type -P syslogd>/dev/null; then

installs="syslogd"

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

elif type -P syslog-ng>/dev/null; then

Indeed this patch is more precise than my simplified one ;)

ugly hack :-/ plus you want mktemp to prevent attacks..

Just to make sure - it was NAK? :)

NAK without mktemp... with mktemp, I am willing to accept the hackiness for the sake of portability :)

#3 lore raw
In reply to a message not in the archive
Quoted 60 lines · Andrey Borzenkov
Quoted 59 lines · On Friday 10 of September 2010 15:48:22 Harald Hoyer wrote:
Quoted 58 lines · Tomasz Pawe³ Gajc

Dnia 2010-09-08, o godz. 18:52:13

Andrey Borzenkov<arvidjaar-JGs/[email protected]> napisa³(a):

Quoted 55 lines

Thomas pointed out that default module path may not be correct (Mandriva installs modules under architecture dependent path). Unfortunately rsyslog does not seem to offer any way to query for
default configuration values. Here is rather hack - try to load non-existing module and fetch path from error message.

Example of error message from version 4.6.4:

rsyslogd: could not load module '/lib64/rsyslog/_No_sUcH_MOduLe.so', dlopen:
/lib64/rsyslog/_No_sUcH_MOduLe.so: cannot open shared object
file: No such file or directory

---

   modules.d/98syslog/install |   17 ++++++++++++++++-
   1 files changed, 16 insertions(+), 1 deletions(-)
(quoted diff) +0 -0

b/modules.d/98syslog/install index 1fd1b6f..e3d02bf 100755

modules.d/98syslog/install +0 -1
@@ -1,6 +1,21 @@
 
   #!/bin/sh
   if type -P rsyslogd>/dev/null; then
 
-

installs="rsyslogd /lib/rsyslog/lmnet.so /lib/rsyslog/imklog.so
/lib/rsyslog/imuxsock.so" + # module path can be changed during
build and currently rsyslog

modules.d/98syslog/install +1 -0
+	# does not provide any means to query for it. Use hack - try

to

modules.d/98syslog/install +8 -0
+	# load non-existent module and look at error message
+	R_CONF=/tmp/dracut.rsyslog.conf.$$
+	R_ERR=/tmp/dracut.rsyslog.err.$$
+	R_MODDIR=
+	echo '$ModLoad _No_sUcH_MOduLe'>   $R_CONF
+	if [ -s $R_CONF ]; then
+		rsyslogd -N 1 -f $R_CONF 2>   $R_ERR>   /dev/null
+		R_MODDIR=$(grep ' could not load

module .*_No_sUcH_MOduLe' $R_ERR)

modules.d/98syslog/install +6 -0
+		R_MODDIR=${R_MODDIR#*could not load module \'}
+		R_MODDIR=${R_MODDIR%\', *}
+		R_MODDIR=${R_MODDIR%/*}
+	fi
+	[ -n "$R_MODDIR" ] || R_MODDIR=/lib/rsyslog
+	installs="rsyslogd $R_MODDIR/lmnet.so $R_MODDIR/imklog.so

$R_MODDIR/imuxsock.so" elif type -P syslogd>/dev/null; then

installs="syslogd"

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

elif type -P syslog-ng>/dev/null; then

Indeed this patch is more precise than my simplified one ;)

ugly hack :-/ plus you want mktemp to prevent attacks..

Just to make sure - it was NAK? :)

Is there some reason to do something this complex instead of simply replacing /lib/rsyslog/ with /lib*/rsyslog/ on that one line?

Signature · 6 lines
        Peter

Computers don't make errors.  What they do, they do on purpose.
		-- Dale

01234567890123456789012345678901234567890123456789012345678901234567890123456789

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw

PATCH 1/1 Be sure and get the right architecture for rsylogd modules.

I've tested this locally on 64-bit with:

dracut -a syslog -f -v foo.img uname -r

And I see this in the output:

I: *** Sourcing module syslog
I: Installing /sbin/rsyslogd
I: Installing /lib64/rsyslog/lmnet.so
I: Installing /lib64/rsyslog/imklog.so
I: Installing /lib64/rsyslog/imuxsock.so
I: Installing /usr/share/dracut/modules.d/98syslog/parse-syslog-opts.sh
I: Installing /usr/share/dracut/modules.d/98syslog/syslog-genrules.sh
I: Installing /usr/share/dracut/modules.d/98syslog/syslog-cleanup.sh
I: Installing /usr/share/dracut/modules.d/98syslog/rsyslogd-start.sh
I: Installing /usr/share/dracut/modules.d/98syslog/rsyslogd-stop.sh
I: Installing /usr/share/dracut/modules.d/98syslog/rsyslog.conf

---
 modules.d/98syslog/install |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
modules.d/98syslog/install +1 -1
index ed5958e..dfaddf3 100755
@@ -3,7 +3,7 @@
 # ex: ts=8 sw=4 sts=4 et filetype=sh
 
 if type -P rsyslogd >/dev/null; then
-    installs="rsyslogd /lib/rsyslog/lmnet.so /lib/rsyslog/imklog.so /lib/rsyslog/imuxsock.so"
+    installs="rsyslogd /lib*/rsyslog/lmnet.so /lib*/rsyslog/imklog.so /lib*/rsyslog/imuxsock.so"
 elif type -P syslogd >/dev/null; then
     installs="syslogd"
 elif type -P syslog-ng >/dev/null; then
Signature · 1 line
1.7.2.3

A message that is not in the archive (sent off-list or not yet received): 1284132744-6659-1-git-send-email-pjones-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#7 lore raw

Re: [PATCH] Be sure and get the right architecture for rsylogd modules.

Quoted 5 lines · Peter Jones

I've tested this locally on 64-bit with:

dracut -a syslog -f -v foo.img uname -r

And I see this in the output:

Harald asked me on IRC to try and also handle the /usr/* case, so my next revision will handle that.

Signature · 6 lines
        Peter

Computers don't make errors.  What they do, they do on purpose.
		-- Dale

01234567890123456789012345678901234567890123456789012345678901234567890123456789

A message that is not in the archive (sent off-list or not yet received): [email protected]

#9 lore raw

PATCH 1/1 Be sure and get the right architecture for rsylogd modules.

I've tested this locally on 64-bit with:

dracut -a syslog -f -v foo.img uname -r

And I see this in the output:

I: *** Sourcing module syslog
I: Installing /sbin/rsyslogd
I: Installing /lib64/rsyslog/lmnet.so
I: Installing /lib64/rsyslog/imklog.so
I: Installing /lib64/rsyslog/imuxsock.so
I: Installing /usr/share/dracut/modules.d/98syslog/parse-syslog-opts.sh
I: Installing /usr/share/dracut/modules.d/98syslog/syslog-genrules.sh
I: Installing /usr/share/dracut/modules.d/98syslog/syslog-cleanup.sh
I: Installing /usr/share/dracut/modules.d/98syslog/rsyslogd-start.sh
I: Installing /usr/share/dracut/modules.d/98syslog/rsyslogd-stop.sh
I: Installing /usr/share/dracut/modules.d/98syslog/rsyslog.conf

---
 modules.d/98syslog/install |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
modules.d/98syslog/install +6 -1
index ed5958e..cca088d 100755
@@ -3,7 +3,12 @@
 # ex: ts=8 sw=4 sts=4 et filetype=sh
 
 if type -P rsyslogd >/dev/null; then
-    installs="rsyslogd /lib/rsyslog/lmnet.so /lib/rsyslog/imklog.so /lib/rsyslog/imuxsock.so"
+    installs="rsyslogd"
+    for i in {"$libdir","$usrlibdir"}/rsyslog/lmnet.so \
+            {"$libdir","$usrlibdir"}/rsyslog/imklog.so \
+            {"$libdir","$usrlibdir"}/rsyslog/imuxsock.so ; do
+        [ -e "$i" ] && installs="$installs $i"
+    done
 elif type -P syslogd >/dev/null; then
     installs="syslogd"
 elif type -P syslog-ng >/dev/null; then
Signature · 1 line
1.7.2.3
#10 lore raw
In reply to a message not in the archive

Dnia 2010-09-10, o godz. 11:15:29
Peter Jones <[email protected]> napisał(a):

Quoted 67 lines · Andrey Borzenkov
Quoted 66 lines · On Friday 10 of September 2010 15:48:22 Harald Hoyer wrote:
Quoted 65 lines · Tomasz Paweł Gajc
Quoted 63 lines

Dnia 2010-09-08, o godz. 18:52:13

Andrey Borzenkov<arvidjaar-JGs/[email protected]> napisał(a):

Quoted 55 lines

Thomas pointed out that default module path may not be correct (Mandriva installs modules under architecture dependent path). Unfortunately rsyslog does not seem to offer any way to query for
default configuration values. Here is rather hack - try to load non-existing module and fetch path from error message.

Example of error message from version 4.6.4:

rsyslogd: could not load module '/lib64/rsyslog/_No_sUcH_MOduLe.so', dlopen:
/lib64/rsyslog/_No_sUcH_MOduLe.so: cannot open shared object
file: No such file or directory

---

   modules.d/98syslog/install |   17 ++++++++++++++++-
   1 files changed, 16 insertions(+), 1 deletions(-)
(quoted diff) +0 -0

b/modules.d/98syslog/install index 1fd1b6f..e3d02bf 100755

modules.d/98syslog/install +0 -1
@@ -1,6 +1,21 @@
 
   #!/bin/sh
   if type -P rsyslogd>/dev/null; then
 
-

installs="rsyslogd /lib/rsyslog/lmnet.so /lib/rsyslog/imklog.so
/lib/rsyslog/imuxsock.so" + # module path can be changed
during build and currently rsyslog

modules.d/98syslog/install +8 -1
+	# does not provide any means to query for it. Use hack
- try to
+	# load non-existent module and look at error message
+	R_CONF=/tmp/dracut.rsyslog.conf.$$
+	R_ERR=/tmp/dracut.rsyslog.err.$$
+	R_MODDIR=
+	echo '$ModLoad _No_sUcH_MOduLe'>   $R_CONF
+	if [ -s $R_CONF ]; then
+		rsyslogd -N 1 -f $R_CONF 2>

$R_ERR> /dev/null

modules.d/98syslog/install +1 -0
+		R_MODDIR=$(grep ' could not load

module .*_No_sUcH_MOduLe' $R_ERR)

modules.d/98syslog/install +6 -0
+		R_MODDIR=${R_MODDIR#*could not load module \'}
+		R_MODDIR=${R_MODDIR%\', *}
+		R_MODDIR=${R_MODDIR%/*}
+	fi
+	[ -n "$R_MODDIR" ] || R_MODDIR=/lib/rsyslog
+	installs="rsyslogd $R_MODDIR/lmnet.so

$R_MODDIR/imklog.so $R_MODDIR/imuxsock.so" elif type -P syslogd>/dev/null; then

Quoted 3 lines

installs="syslogd"

elif type -P syslog-ng>/dev/null; then

Indeed this patch is more precise than my simplified one ;)

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

ugly hack :-/ plus you want mktemp to prevent attacks..

Just to make sure - it was NAK? :)

Is there some reason to do something this complex instead of simply replacing /lib/rsyslog/ with /lib*/rsyslog/ on that one line?

Well you can always try my simple solution:

diff -Naur dracut-007//modules.d/98syslog/install dracut-007.tpg//modules.d/98syslog/install ---
dracut-007//modules.d/98syslog/install 2010-08-09
14:13:51.000000000 +0000 +++
dracut-007.tpg//modules.d/98syslog/install 2010-09-04
23:00:12.000000000 +0000 @@ -1,6 +1,13 @@ #!/bin/sh +
+if ldd /sbin/rsyslogd | grep -q lib64; then
+ LIBDIR="/lib64"
+else
+ LIBDIR="/lib"
+fi
+
if which rsyslogd >/dev/null; then
-
installs="rsyslogd /usr/lib/rsyslog/lmnet.so /usr/lib/rsyslog/imklog.so /usr/lib/rsyslog/imuxsock.so"
+ installs="rsyslogd ${LIBDIR}/rsyslog/lmnet.so
${LIBDIR}/rsyslog/imklog.so ${LIBDIR}/rsyslog/imuxsock.so" elif which
syslogd >/dev/null; then installs="syslogd"
elif which syslog-ng >/dev/null; then

http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/dracut/current/SOURCES/dracut-007-add-rsyslog-library-patch-check.patch

Signature · 5 lines
Regards
TPG

http://cia.vc/stats/author/tpg
---