From: Daniel J Walsh <dwalsh@redhat.com>
To: Stephen Smalley <sds@tycho.nsa.gov>
Cc: Joshua Brindle <method@manicmethod.com>,
SE Linux <selinux@tycho.nsa.gov>
Subject: Re: Change default error handling in libselinux matchpathcon to use syslog instead of stderr.
Date: Tue, 18 Sep 2007 15:54:51 -0400 [thread overview]
Message-ID: <46F02D0B.9020809@redhat.com> (raw)
In-Reply-To: <1190137543.14037.77.camel@moss-spartans.epoch.ncsc.mil>
[-- 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 --]
next prev parent reply other threads:[~2007-09-18 19:54 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2007-09-19 14:03 ` Stephen Smalley
2007-09-19 17:12 ` Eamon Walsh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=46F02D0B.9020809@redhat.com \
--to=dwalsh@redhat.com \
--cc=method@manicmethod.com \
--cc=sds@tycho.nsa.gov \
--cc=selinux@tycho.nsa.gov \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.