* Change default error handling in libselinux matchpathcon to use syslog instead of stderr.
@ 2007-09-18 15:35 Daniel J Walsh
2007-09-18 16:43 ` Stephen Smalley
2007-09-18 17:09 ` Joshua Brindle
0 siblings, 2 replies; 10+ messages in thread
From: Daniel J Walsh @ 2007-09-18 15:35 UTC (permalink / raw)
To: Stephen Smalley, SE Linux
[-- Attachment #1: Type: text/plain, Size: 411 bytes --]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Current behavior causes problems with network applications.
https://bugzilla.redhat.com/show_bug.cgi?id=273081
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
iD8DBQFG7/AnrlYvE4MpobMRAksuAJ4uqcUDsSlB9uEpXePUEje39kNAywCeJbDE
sZ99tA7s4PgSxD/RnS4MHdg=
=g4kG
-----END PGP SIGNATURE-----
[-- Attachment #2: diff --]
[-- Type: text/plain, Size: 702 bytes --]
diff --exclude-from=exclude -N -u -r nsalibselinux/src/matchpathcon.c libselinux-2.0.33/src/matchpathcon.c
--- nsalibselinux/src/matchpathcon.c 2007-08-10 11:58:34.000000000 -0400
+++ libselinux-2.0.33/src/matchpathcon.c 2007-09-18 11:28:07.000000000 -0400
@@ -2,6 +2,7 @@
#include <string.h>
#include <errno.h>
#include <stdio.h>
+#include <syslog.h>
#include "selinux_internal.h"
#include "label_internal.h"
#include "callbacks.h"
@@ -55,10 +56,12 @@
#endif
default_printf(const char *fmt, ...)
{
+ char buf[BUFSIZ];
va_list ap;
va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
+ vsnprintf(buf, sizeof(buf) - 1, fmt, ap);
va_end(ap);
+ syslog(LOG_ERR, buf, strlen(buf));
}
void
[-- Attachment #3: diff.sig --]
[-- Type: application/octet-stream, Size: 65 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Change default error handling in libselinux matchpathcon to use syslog instead of stderr.
2007-09-18 15:35 Change default error handling in libselinux matchpathcon to use syslog instead of stderr Daniel J Walsh
@ 2007-09-18 16:43 ` Stephen Smalley
2007-09-18 19:47 ` Daniel J Walsh
2007-09-18 17:09 ` Joshua Brindle
1 sibling, 1 reply; 10+ messages in thread
From: Stephen Smalley @ 2007-09-18 16:43 UTC (permalink / raw)
To: Daniel J Walsh; +Cc: SE Linux, Eamon Walsh, Karl MacMillan, Joshua Brindle
On Tue, 2007-09-18 at 11:35 -0400, Daniel J Walsh wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Current behavior causes problems with network applications.
>
> https://bugzilla.redhat.com/show_bug.cgi?id=273081
I'm not sure about changing current behavior, as that is effectively an
"interface" change. Or if it isn't, then there are other such changes I
would make too (e.g. changing the default for SETLOCALDEFS in libselinux
comes to mind).
What if they used the newer interfaces introduced by Eamon (selabel*)?
setfiles has already been rewritten by him to use those interfaces, and
thus matchpathcon is a legacy interface at this point. Does the same
problem exist there?
I suppose that doesn't help you though with RHEL 5, as it would only
have the older interfaces.
Changing the interface from one arbitrary default (stderr) to another
arbitrary default (syslog) doesn't seem like an improvement, although it
would fix this particular issue I suppose. We would need to at least
make sure that setfiles -c continues to report the error messages as
expected.
One comment below on the code itself.
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.7 (GNU/Linux)
> Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
>
> iD8DBQFG7/AnrlYvE4MpobMRAksuAJ4uqcUDsSlB9uEpXePUEje39kNAywCeJbDE
> sZ99tA7s4PgSxD/RnS4MHdg=
> =g4kG
> -----END PGP SIGNATURE-----
> plain text document attachment (diff)
> diff --exclude-from=exclude -N -u -r nsalibselinux/src/matchpathcon.c libselinux-2.0.33/src/matchpathcon.c
> --- nsalibselinux/src/matchpathcon.c 2007-08-10 11:58:34.000000000 -0400
> +++ libselinux-2.0.33/src/matchpathcon.c 2007-09-18 11:28:07.000000000 -0400
> @@ -2,6 +2,7 @@
> #include <string.h>
> #include <errno.h>
> #include <stdio.h>
> +#include <syslog.h>
> #include "selinux_internal.h"
> #include "label_internal.h"
> #include "callbacks.h"
> @@ -55,10 +56,12 @@
> #endif
> default_printf(const char *fmt, ...)
> {
> + char buf[BUFSIZ];
> va_list ap;
> va_start(ap, fmt);
> - vfprintf(stderr, fmt, ap);
> + vsnprintf(buf, sizeof(buf) - 1, fmt, ap);
> va_end(ap);
> + syslog(LOG_ERR, buf, strlen(buf));
> }
Could you use vsyslog() instead to avoid the need for a fixed size
buffer?
>
> void
--
Stephen Smalley
National Security Agency
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Change default error handling in libselinux matchpathcon to use syslog instead of stderr.
2007-09-18 15:35 Change default error handling in libselinux matchpathcon to use syslog instead of stderr Daniel J Walsh
2007-09-18 16:43 ` Stephen Smalley
@ 2007-09-18 17:09 ` Joshua Brindle
2007-09-18 17:23 ` Stephen Smalley
1 sibling, 1 reply; 10+ messages in thread
From: Joshua Brindle @ 2007-09-18 17:09 UTC (permalink / raw)
To: Daniel J Walsh; +Cc: Stephen Smalley, SE Linux
Daniel J Walsh wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Current behavior causes problems with network applications.
>
> https://bugzilla.redhat.com/show_bug.cgi?id=273081
>
Wait, what?
I don't think it is an improvement to call the command line matchpathcon
applications and have the logs go somewhere not visible by the user. IMO
we should take the same approach libsemanage and libsepol did where the
logging callbacks can be overridden by specific users of the library but
for the command line applications the output still goes to stderr.
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Change default error handling in libselinux matchpathcon to use syslog instead of stderr.
2007-09-18 17:09 ` Joshua Brindle
@ 2007-09-18 17:23 ` Stephen Smalley
2007-09-18 17:43 ` Joshua Brindle
0 siblings, 1 reply; 10+ messages in thread
From: Stephen Smalley @ 2007-09-18 17:23 UTC (permalink / raw)
To: Joshua Brindle; +Cc: Daniel J Walsh, SE Linux
On Tue, 2007-09-18 at 13:09 -0400, Joshua Brindle wrote:
> Daniel J Walsh wrote:
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > Current behavior causes problems with network applications.
> >
> > https://bugzilla.redhat.com/show_bug.cgi?id=273081
> >
>
> Wait, what?
>
> I don't think it is an improvement to call the command line matchpathcon
> applications and have the logs go somewhere not visible by the user. IMO
> we should take the same approach libsemanage and libsepol did where the
> logging callbacks can be overridden by specific users of the library but
> for the command line applications the output still goes to stderr.
You already can override the callback (set_matchpathcon_printf), but the
claim in the bug report is that isn't usable from a library function
that calls matchpathcon because it doesn't know whether it has already
been set by the application.
--
Stephen Smalley
National Security Agency
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Change default error handling in libselinux matchpathcon to use syslog instead of stderr.
2007-09-18 17:23 ` Stephen Smalley
@ 2007-09-18 17:43 ` Joshua Brindle
2007-09-18 17:45 ` Stephen Smalley
0 siblings, 1 reply; 10+ messages in thread
From: Joshua Brindle @ 2007-09-18 17:43 UTC (permalink / raw)
To: Stephen Smalley; +Cc: Daniel J Walsh, SE Linux
Stephen Smalley wrote:
> On Tue, 2007-09-18 at 13:09 -0400, Joshua Brindle wrote:
>
>> Daniel J Walsh wrote:
>>
>>> -----BEGIN PGP SIGNED MESSAGE-----
>>> Hash: SHA1
>>>
>>> Current behavior causes problems with network applications.
>>>
>>> https://bugzilla.redhat.com/show_bug.cgi?id=273081
>>>
>>>
>> Wait, what?
>>
>> I don't think it is an improvement to call the command line matchpathcon
>> applications and have the logs go somewhere not visible by the user. IMO
>> we should take the same approach libsemanage and libsepol did where the
>> logging callbacks can be overridden by specific users of the library but
>> for the command line applications the output still goes to stderr.
>>
>
> You already can override the callback (set_matchpathcon_printf), but the
> claim in the bug report is that isn't usable from a library function
> that calls matchpathcon because it doesn't know whether it has already
> been set by the application.
>
Hrm... so the alternative is to send it to syslog? I don't buy it. Can
we just add an interface to see if the default callbacks have been
overridden?
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Change default error handling in libselinux matchpathcon to use syslog instead of stderr.
2007-09-18 17:43 ` Joshua Brindle
@ 2007-09-18 17:45 ` Stephen Smalley
2007-09-18 19:54 ` Daniel J Walsh
2007-09-19 17:12 ` Eamon Walsh
0 siblings, 2 replies; 10+ messages in thread
From: Stephen Smalley @ 2007-09-18 17:45 UTC (permalink / raw)
To: Joshua Brindle; +Cc: Daniel J Walsh, SE Linux
On Tue, 2007-09-18 at 13:43 -0400, Joshua Brindle wrote:
> Stephen Smalley wrote:
> > On Tue, 2007-09-18 at 13:09 -0400, Joshua Brindle wrote:
> >
> >> Daniel J Walsh wrote:
> >>
> >>> -----BEGIN PGP SIGNED MESSAGE-----
> >>> Hash: SHA1
> >>>
> >>> Current behavior causes problems with network applications.
> >>>
> >>> https://bugzilla.redhat.com/show_bug.cgi?id=273081
> >>>
> >>>
> >> Wait, what?
> >>
> >> I don't think it is an improvement to call the command line matchpathcon
> >> applications and have the logs go somewhere not visible by the user. IMO
> >> we should take the same approach libsemanage and libsepol did where the
> >> logging callbacks can be overridden by specific users of the library but
> >> for the command line applications the output still goes to stderr.
> >>
> >
> > You already can override the callback (set_matchpathcon_printf), but the
> > claim in the bug report is that isn't usable from a library function
> > that calls matchpathcon because it doesn't know whether it has already
> > been set by the application.
> >
>
> Hrm... so the alternative is to send it to syslog? I don't buy it. Can
> we just add an interface to see if the default callbacks have been
> overridden?
Yep. And it should be based on the newer interfaces. There is already
a selinux_set_callback() and adding a selinux_get_callback() should be
trivial. setfiles is already rewritten to use the new interfaces in
trunk, and we should be moving everything off of matchpathcon and onto
selabel_lookup.
For RHEL 5, I suppose there might be a matchpathcon-specific interface
for getting the callback.
--
Stephen Smalley
National Security Agency
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Change default error handling in libselinux matchpathcon to use syslog instead of stderr.
2007-09-18 16:43 ` Stephen Smalley
@ 2007-09-18 19:47 ` Daniel J Walsh
0 siblings, 0 replies; 10+ messages in thread
From: Daniel J Walsh @ 2007-09-18 19:47 UTC (permalink / raw)
To: Stephen Smalley; +Cc: SE Linux, Eamon Walsh, Karl MacMillan, Joshua Brindle
[-- Attachment #1: Type: text/plain, Size: 2375 bytes --]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Stephen Smalley wrote:
> On Tue, 2007-09-18 at 11:35 -0400, Daniel J Walsh wrote:
> Current behavior causes problems with network applications.
>
> https://bugzilla.redhat.com/show_bug.cgi?id=273081
>
>> I'm not sure about changing current behavior, as that is effectively an
>> "interface" change. Or if it isn't, then there are other such changes I
>> would make too (e.g. changing the default for SETLOCALDEFS in libselinux
>> comes to mind).
>
>> What if they used the newer interfaces introduced by Eamon (selabel*)?
>> setfiles has already been rewritten by him to use those interfaces, and
>> thus matchpathcon is a legacy interface at this point. Does the same
>> problem exist there?
>
>> I suppose that doesn't help you though with RHEL 5, as it would only
>> have the older interfaces.
>
>> Changing the interface from one arbitrary default (stderr) to another
>> arbitrary default (syslog) doesn't seem like an improvement, although it
>> would fix this particular issue I suppose. We would need to at least
>> make sure that setfiles -c continues to report the error messages as
>> expected.
>
>> One comment below on the code itself.
>
plain text document attachment (diff)
diff --exclude-from=exclude -N -u -r nsalibselinux/src/matchpathcon.c
libselinux-2.0.33/src/matchpathcon.c
- --- nsalibselinux/src/matchpathcon.c 2007-08-10 11:58:34.000000000 -0400
+++ libselinux-2.0.33/src/matchpathcon.c 2007-09-18 11:28:07.000000000 -0400
@@ -2,6 +2,7 @@
#include <string.h>
#include <errno.h>
#include <stdio.h>
+#include <syslog.h>
#include "selinux_internal.h"
#include "label_internal.h"
#include "callbacks.h"
@@ -55,10 +56,12 @@
#endif
default_printf(const char *fmt, ...)
{
+ char buf[BUFSIZ];
va_list ap;
va_start(ap, fmt);
- - vfprintf(stderr, fmt, ap);
+ vsnprintf(buf, sizeof(buf) - 1, fmt, ap);
va_end(ap);
+ syslog(LOG_ERR, buf, strlen(buf));
}
> Could you use vsyslog() instead to avoid the need for a fixed size
> buffer?
void
Sure, I did not know that interface existed.
man syslog and
man 3 syslog are different.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
iD8DBQFG8CtXrlYvE4MpobMRArAnAJsGDG1/UQtq8O/3sOWsWg6mbs+OaACg11BH
44PynbOo4cSB9hcAq66yjiw=
=dPQV
-----END PGP SIGNATURE-----
[-- Attachment #2: diff --]
[-- Type: text/plain, Size: 572 bytes --]
diff --exclude-from=exclude -N -u -r nsalibselinux/src/matchpathcon.c libselinux-2.0.33/src/matchpathcon.c
--- nsalibselinux/src/matchpathcon.c 2007-08-10 11:58:34.000000000 -0400
+++ libselinux-2.0.33/src/matchpathcon.c 2007-09-18 15:45:42.000000000 -0400
@@ -2,6 +2,7 @@
#include <string.h>
#include <errno.h>
#include <stdio.h>
+#include <syslog.h>
#include "selinux_internal.h"
#include "label_internal.h"
#include "callbacks.h"
@@ -57,7 +58,7 @@
{
va_list ap;
va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
+ vsyslog(LOG_ERR, fmt, ap);
va_end(ap);
}
[-- Attachment #3: diff.sig --]
[-- Type: application/octet-stream, Size: 65 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Change default error handling in libselinux matchpathcon to use syslog instead of stderr.
2007-09-18 17:45 ` Stephen Smalley
@ 2007-09-18 19:54 ` Daniel J Walsh
2007-09-19 14:03 ` Stephen Smalley
2007-09-19 17:12 ` Eamon Walsh
1 sibling, 1 reply; 10+ messages in thread
From: Daniel J Walsh @ 2007-09-18 19:54 UTC (permalink / raw)
To: Stephen Smalley; +Cc: Joshua Brindle, SE Linux
[-- Attachment #1: Type: text/plain, Size: 2271 bytes --]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Stephen Smalley wrote:
> On Tue, 2007-09-18 at 13:43 -0400, Joshua Brindle wrote:
>> Stephen Smalley wrote:
>>> On Tue, 2007-09-18 at 13:09 -0400, Joshua Brindle wrote:
>>>
>>>> Daniel J Walsh wrote:
>>>>
>>>>> -----BEGIN PGP SIGNED MESSAGE-----
>>>>> Hash: SHA1
>>>>>
>>>>> Current behavior causes problems with network applications.
>>>>>
>>>>> https://bugzilla.redhat.com/show_bug.cgi?id=273081
>>>>>
>>>>>
>>>> Wait, what?
>>>>
>>>> I don't think it is an improvement to call the command line matchpathcon
>>>> applications and have the logs go somewhere not visible by the user. IMO
>>>> we should take the same approach libsemanage and libsepol did where the
>>>> logging callbacks can be overridden by specific users of the library but
>>>> for the command line applications the output still goes to stderr.
>>>>
>>> You already can override the callback (set_matchpathcon_printf), but the
>>> claim in the bug report is that isn't usable from a library function
>>> that calls matchpathcon because it doesn't know whether it has already
>>> been set by the application.
>>>
>> Hrm... so the alternative is to send it to syslog? I don't buy it. Can
>> we just add an interface to see if the default callbacks have been
>> overridden?
>
> Yep. And it should be based on the newer interfaces. There is already
> a selinux_set_callback() and adding a selinux_get_callback() should be
> trivial. setfiles is already rewritten to use the new interfaces in
> trunk, and we should be moving everything off of matchpathcon and onto
> selabel_lookup.
>
> For RHEL 5, I suppose there might be a matchpathcon-specific interface
> for getting the callback.
>
I would still prefer the default not to spew to stdout where an admin
might not see it or it might not get caught to using syslog.
Updated diff to include changing matchpathcon the exec
udev/install/mkinitrd/kerberos libraries and probably a few others are
using this interface.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
iD8DBQFG8C0LrlYvE4MpobMRApKVAKCx3bLTKq8pDe+rgARw6DdUo7O0wACgr5Cn
isUZTJ4Dh8jifv0uXaZ4xWI=
=HciW
-----END PGP SIGNATURE-----
[-- Attachment #2: diff --]
[-- Type: text/plain, Size: 1375 bytes --]
diff --exclude-from=exclude -N -u -r nsalibselinux/src/matchpathcon.c libselinux-2.0.33/src/matchpathcon.c
--- nsalibselinux/src/matchpathcon.c 2007-08-10 11:58:34.000000000 -0400
+++ libselinux-2.0.33/src/matchpathcon.c 2007-09-18 15:45:42.000000000 -0400
@@ -2,6 +2,7 @@
#include <string.h>
#include <errno.h>
#include <stdio.h>
+#include <syslog.h>
#include "selinux_internal.h"
#include "label_internal.h"
#include "callbacks.h"
@@ -57,7 +58,7 @@
{
va_list ap;
va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
+ vsyslog(LOG_ERR, fmt, ap);
va_end(ap);
}
diff --exclude-from=exclude -N -u -r nsalibselinux/utils/matchpathcon.c libselinux-2.0.33/utils/matchpathcon.c
--- nsalibselinux/utils/matchpathcon.c 2007-07-16 14:20:45.000000000 -0400
+++ libselinux-2.0.33/utils/matchpathcon.c 2007-09-18 15:50:31.000000000 -0400
@@ -17,10 +17,24 @@
exit(1);
}
+static void
+#ifdef __GNUC__
+ __attribute__ ((format(printf, 1, 2)))
+#endif
+ myprintf(const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+}
+
int printmatchpathcon(char *path, int header, int mode)
{
char *buf;
- int rc = matchpathcon(path, mode, &buf);
+ int rc;
+ set_matchpathcon_printf(myprintf);
+ rc = matchpathcon(path, mode, &buf);
if (rc < 0) {
fprintf(stderr, "matchpathcon(%s) failed: %s\n", path,
strerror(errno));
[-- Attachment #3: diff.sig --]
[-- Type: application/octet-stream, Size: 65 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Change default error handling in libselinux matchpathcon to use syslog instead of stderr.
2007-09-18 19:54 ` Daniel J Walsh
@ 2007-09-19 14:03 ` Stephen Smalley
0 siblings, 0 replies; 10+ messages in thread
From: Stephen Smalley @ 2007-09-19 14:03 UTC (permalink / raw)
To: Daniel J Walsh; +Cc: Joshua Brindle, SE Linux
On Tue, 2007-09-18 at 15:54 -0400, Daniel J Walsh wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Stephen Smalley wrote:
> > On Tue, 2007-09-18 at 13:43 -0400, Joshua Brindle wrote:
> >> Stephen Smalley wrote:
> >>> On Tue, 2007-09-18 at 13:09 -0400, Joshua Brindle wrote:
> >>>
> >>>> Daniel J Walsh wrote:
> >>>>
> >>>>> -----BEGIN PGP SIGNED MESSAGE-----
> >>>>> Hash: SHA1
> >>>>>
> >>>>> Current behavior causes problems with network applications.
> >>>>>
> >>>>> https://bugzilla.redhat.com/show_bug.cgi?id=273081
> >>>>>
> >>>>>
> >>>> Wait, what?
> >>>>
> >>>> I don't think it is an improvement to call the command line matchpathcon
> >>>> applications and have the logs go somewhere not visible by the user. IMO
> >>>> we should take the same approach libsemanage and libsepol did where the
> >>>> logging callbacks can be overridden by specific users of the library but
> >>>> for the command line applications the output still goes to stderr.
> >>>>
> >>> You already can override the callback (set_matchpathcon_printf), but the
> >>> claim in the bug report is that isn't usable from a library function
> >>> that calls matchpathcon because it doesn't know whether it has already
> >>> been set by the application.
> >>>
> >> Hrm... so the alternative is to send it to syslog? I don't buy it. Can
> >> we just add an interface to see if the default callbacks have been
> >> overridden?
> >
> > Yep. And it should be based on the newer interfaces. There is already
> > a selinux_set_callback() and adding a selinux_get_callback() should be
> > trivial. setfiles is already rewritten to use the new interfaces in
> > trunk, and we should be moving everything off of matchpathcon and onto
> > selabel_lookup.
> >
> > For RHEL 5, I suppose there might be a matchpathcon-specific interface
> > for getting the callback.
> >
> I would still prefer the default not to spew to stdout where an admin
> might not see it or it might not get caught to using syslog.
>
> Updated diff to include changing matchpathcon the exec
>
> udev/install/mkinitrd/kerberos libraries and probably a few others are
> using this interface.
I added a comment to the bug report to get feedback on the alternate
proposal of adding a get_matchpathcon_printf interface that could be
used by library code to get the current function pointer (if set) prior
to manipulating it via set_matchpathcon_printf; then the library can
reset it to the original value afterward. That avoids changing the
default behavior of the existing interface while letting library callers
override safely, I think.
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.7 (GNU/Linux)
> Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
>
> iD8DBQFG8C0LrlYvE4MpobMRApKVAKCx3bLTKq8pDe+rgARw6DdUo7O0wACgr5Cn
> isUZTJ4Dh8jifv0uXaZ4xWI=
> =HciW
> -----END PGP SIGNATURE-----
> plain text document attachment (diff)
> diff --exclude-from=exclude -N -u -r nsalibselinux/src/matchpathcon.c libselinux-2.0.33/src/matchpathcon.c
> --- nsalibselinux/src/matchpathcon.c 2007-08-10 11:58:34.000000000 -0400
> +++ libselinux-2.0.33/src/matchpathcon.c 2007-09-18 15:45:42.000000000 -0400
> @@ -2,6 +2,7 @@
> #include <string.h>
> #include <errno.h>
> #include <stdio.h>
> +#include <syslog.h>
> #include "selinux_internal.h"
> #include "label_internal.h"
> #include "callbacks.h"
> @@ -57,7 +58,7 @@
> {
> va_list ap;
> va_start(ap, fmt);
> - vfprintf(stderr, fmt, ap);
> + vsyslog(LOG_ERR, fmt, ap);
> va_end(ap);
> }
>
> diff --exclude-from=exclude -N -u -r nsalibselinux/utils/matchpathcon.c libselinux-2.0.33/utils/matchpathcon.c
> --- nsalibselinux/utils/matchpathcon.c 2007-07-16 14:20:45.000000000 -0400
> +++ libselinux-2.0.33/utils/matchpathcon.c 2007-09-18 15:50:31.000000000 -0400
> @@ -17,10 +17,24 @@
> exit(1);
> }
>
> +static void
> +#ifdef __GNUC__
> + __attribute__ ((format(printf, 1, 2)))
> +#endif
> + myprintf(const char *fmt, ...)
> +{
> + va_list ap;
> + va_start(ap, fmt);
> + vfprintf(stderr, fmt, ap);
> + va_end(ap);
> +}
> +
> int printmatchpathcon(char *path, int header, int mode)
> {
> char *buf;
> - int rc = matchpathcon(path, mode, &buf);
> + int rc;
> + set_matchpathcon_printf(myprintf);
> + rc = matchpathcon(path, mode, &buf);
> if (rc < 0) {
> fprintf(stderr, "matchpathcon(%s) failed: %s\n", path,
> strerror(errno));
--
Stephen Smalley
National Security Agency
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Change default error handling in libselinux matchpathcon to use syslog instead of stderr.
2007-09-18 17:45 ` Stephen Smalley
2007-09-18 19:54 ` Daniel J Walsh
@ 2007-09-19 17:12 ` Eamon Walsh
1 sibling, 0 replies; 10+ messages in thread
From: Eamon Walsh @ 2007-09-19 17:12 UTC (permalink / raw)
To: Stephen Smalley; +Cc: Joshua Brindle, Daniel J Walsh, SE Linux
Stephen Smalley wrote:
> On Tue, 2007-09-18 at 13:43 -0400, Joshua Brindle wrote:
>> Stephen Smalley wrote:
[...]
>>> You already can override the callback (set_matchpathcon_printf), but the
>>> claim in the bug report is that isn't usable from a library function
>>> that calls matchpathcon because it doesn't know whether it has already
>>> been set by the application.
>>>
>> Hrm... so the alternative is to send it to syslog? I don't buy it. Can
>> we just add an interface to see if the default callbacks have been
>> overridden?
>
> Yep. And it should be based on the newer interfaces. There is already
> a selinux_set_callback() and adding a selinux_get_callback() should be
> trivial. setfiles is already rewritten to use the new interfaces in
> trunk, and we should be moving everything off of matchpathcon and onto
> selabel_lookup.
We could add a get function, and/or modify selinux_set_callback(),
currently void, to return the previous callback in the same way as
signal(2).
>
> For RHEL 5, I suppose there might be a matchpathcon-specific interface
> for getting the callback.
>
--
Eamon Walsh <ewalsh@tycho.nsa.gov>
National Security Agency
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2007-09-19 17:12 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-18 15:35 Change default error handling in libselinux matchpathcon to use syslog instead of stderr Daniel J Walsh
2007-09-18 16:43 ` Stephen Smalley
2007-09-18 19:47 ` Daniel J Walsh
2007-09-18 17:09 ` Joshua Brindle
2007-09-18 17:23 ` Stephen Smalley
2007-09-18 17:43 ` Joshua Brindle
2007-09-18 17:45 ` Stephen Smalley
2007-09-18 19:54 ` Daniel J Walsh
2007-09-19 14:03 ` Stephen Smalley
2007-09-19 17:12 ` Eamon Walsh
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.