smack_new_label_from_self@LIBSMACK 1.0
smack_new_label_from_socket@LIBSMACK 1.0
smack_revoke_subject@LIBSMACK 1.0
+ smack_set_label_for_self@LIBSMACK 1.0
smack_have_access.3 \
smack_new_label_from_self.3 \
smack_new_label_from_socket.3 \
+ smack_set_label_for_self.3 \
smack_revoke_subject.3 \
chsmack.8 \
smackcipso.8 \
'\" t
.\" This file is part of libsmack
.\" Copyright (C) 2012 Intel Corporation
+.\" Copyright (C) 2012 Samsung Electronics Co.
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public License
.\"
.\" Author:
.\" Brian McGillion <brian.mcgillion@intel.com>
+.\" Rafal Krypa <r.krypa@samsung.com>
.\"
-.TH "SMACK_HAVE_ACCESS" "3" "02/05/2012" "Libsmack 1\&.0"
+.TH "SMACK_HAVE_ACCESS" "3" "06/20/2012" "Libsmack 1\&.0"
.SH NAME
smack_have_access, smack_new_label_from_self, smack_new_label_from_socket \- Userspace interaction with Smack
.SH SYNOPSIS
.br
.BI "int smack_new_label_from_self(char **" label ");"
.br
+.BI "int smack_set_label_for_self(char **" label ");"
+.br
.BI "int smack_new_label_from_socket(int " fd ", char **" label ");"
.sp
.SH DESCRIPTION
.I label
when it is no longer required.
.PP
+.BR smack_set_label_for_self ()
+sets the context of the current process to
+.IR label .
+The calling process must have the CAP_MAC_ADMIN capability.
+.PP
.BR smack_new_label_from_socket ()
takes the file descriptor,
.IR "fd" ,
--- /dev/null
+.so man3/smack_have_access.3
return 0;
}
+int smack_set_label_for_self(const char *label)
+{
+ int len;
+ int fd;
+ int ret;
+
+ len = strnlen(label, SMACK_LABEL_LEN + 1);
+ if (len > SMACK_LABEL_LEN)
+ return -1;
+
+ fd = open(SELF_LABEL_FILE, O_WRONLY);
+ if (fd < 0)
+ return -1;
+
+ ret = write(fd, label, len);
+ close(fd);
+
+ return (ret < 0) ? -1 : 0;
+}
+
int smack_revoke_subject(const char *subject)
{
int ret;
smack_smackfs_path;
smack_new_label_from_self;
smack_new_label_from_socket;
+ smack_set_label_for_self;
smack_revoke_subject;
local:
*;
int smack_new_label_from_socket(int fd, char **label);
/*!
+ * Set the label associated with the callers process.
+ * Caller must be run by privileged user to succeed.
+ *
+ * @param label to set
+ * @return 0 on success and negative value on failure.
+ */
+int smack_set_label_for_self(const char *label);
+
+/*!
* Revoke all rules for a subject label.
*
* @param subject subject to revoke