syslog: use defined constants instead of raw numbers

Right now the syslog "type" action are just raw numbers which makes
the source difficult to follow.  This patch replaces the raw numbers
with defined constants for some level of sanity.

Signed-off-by: Kees Cook <kees.cook@canonical.com>
Acked-by: John Johansen <john.johansen@canonical.com>
Acked-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: James Morris <jmorris@namei.org>
This commit is contained in:
Kees Cook
2010-02-03 15:37:13 -08:00
committed by James Morris
parent 002345925e
commit d78ca3cd73
5 changed files with 61 additions and 43 deletions

View File

@@ -897,9 +897,10 @@ error:
int cap_syslog(int type, bool from_file)
{
/* /proc/kmsg can open be opened by CAP_SYS_ADMIN */
if (type != 1 && from_file)
if (type != SYSLOG_ACTION_OPEN && from_file)
return 0;
if ((type != 3 && type != 10) && !capable(CAP_SYS_ADMIN))
if ((type != SYSLOG_ACTION_READ_ALL &&
type != SYSLOG_ACTION_SIZE_BUFFER) && !capable(CAP_SYS_ADMIN))
return -EPERM;
return 0;
}