Skip to content

Commit 832cbd9

Browse files
eparisxjamesmorris
authored andcommitted
SELinux: turn mount options strings into defines
Convert the strings used for mount options into #defines rather than retyping the string throughout the SELinux code. Signed-off-by: Eric Paris <eparis@redhat.com> Acked-by: Stephen Smalley <sds@tycho.nsa.gov> Signed-off-by: James Morris <jmorris@namei.org>
1 parent 0e55a00 commit 832cbd9

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

‎security/selinux/hooks.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,10 @@ enum {
321321
};
322322

323323
static match_table_t tokens = {
324-
{Opt_context, "context=%s"},
325-
{Opt_fscontext, "fscontext=%s"},
326-
{Opt_defcontext, "defcontext=%s"},
327-
{Opt_rootcontext, "rootcontext=%s"},
324+
{Opt_context, CONTEXT_STR "%s"},
325+
{Opt_fscontext, FSCONTEXT_STR "%s"},
326+
{Opt_defcontext, DEFCONTEXT_STR "%s"},
327+
{Opt_rootcontext, ROOTCONTEXT_STR "%s"},
328328
{Opt_error, NULL},
329329
};
330330

@@ -2287,10 +2287,10 @@ static inline int match_prefix(char *prefix, int plen, char *option, int olen)
22872287

22882288
static inline int selinux_option(char *option, int len)
22892289
{
2290-
return (match_prefix("context=", sizeof("context=")-1, option, len) ||
2291-
match_prefix("fscontext=", sizeof("fscontext=")-1, option, len) ||
2292-
match_prefix("defcontext=", sizeof("defcontext=")-1, option, len) ||
2293-
match_prefix("rootcontext=", sizeof("rootcontext=")-1, option, len));
2290+
return (match_prefix(CONTEXT_STR, sizeof(CONTEXT_STR)-1, option, len) ||
2291+
match_prefix(FSCONTEXT_STR, sizeof(FSCONTEXT_STR)-1, option, len) ||
2292+
match_prefix(DEFCONTEXT_STR, sizeof(DEFCONTEXT_STR)-1, option, len) ||
2293+
match_prefix(ROOTCONTEXT_STR, sizeof(ROOTCONTEXT_STR)-1, option, len));
22942294
}
22952295

22962296
static inline void take_option(char **to, char *from, int *first, int len)

‎security/selinux/include/security.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@
4141
#define ROOTCONTEXT_MNT 0x04
4242
#define DEFCONTEXT_MNT 0x08
4343

44+
#define CONTEXT_STR "context="
45+
#define FSCONTEXT_STR "fscontext="
46+
#define ROOTCONTEXT_STR "rootcontext="
47+
#define DEFCONTEXT_STR "defcontext="
48+
4449
struct netlbl_lsm_secattr;
4550

4651
extern int selinux_enabled;

0 commit comments

Comments
 (0)