]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - security/selinux/exports.c
[PATCH] audit inode patch
[mirror_ubuntu-jammy-kernel.git] / security / selinux / exports.c
CommitLineData
376bd9cb
DG
1/*
2 * SELinux services exported to the rest of the kernel.
3 *
4 * Author: James Morris <jmorris@redhat.com>
5 *
6 * Copyright (C) 2005 Red Hat, Inc., James Morris <jmorris@redhat.com>
7 * Copyright (C) 2006 Trusted Computer Solutions, Inc. <dgoeddel@trustedcs.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2,
11 * as published by the Free Software Foundation.
12 */
13#include <linux/types.h>
14#include <linux/kernel.h>
15#include <linux/module.h>
16#include <linux/selinux.h>
1b50eed9 17#include <linux/fs.h>
376bd9cb
DG
18
19#include "security.h"
20#include "objsec.h"
21
22void selinux_task_ctxid(struct task_struct *tsk, u32 *ctxid)
23{
24 struct task_security_struct *tsec = tsk->security;
25 if (selinux_enabled)
26 *ctxid = tsec->sid;
27 else
28 *ctxid = 0;
29}
1b50eed9
SG
30
31int selinux_ctxid_to_string(u32 ctxid, char **ctx, u32 *ctxlen)
32{
33 if (selinux_enabled)
34 return security_sid_to_context(ctxid, ctx, ctxlen);
35 else {
36 *ctx = NULL;
37 *ctxlen = 0;
38 }
39
40 return 0;
41}
42
43void selinux_get_inode_sid(const struct inode *inode, u32 *sid)
44{
45 if (selinux_enabled) {
46 struct inode_security_struct *isec = inode->i_security;
47 *sid = isec->sid;
48 return;
49 }
50 *sid = 0;
51}
52