diff mbox

ACPI: Only allow users with CAP_SYS_RAWIO rights to overwrite ACPI funcs at runtime

Message ID 201209251725.13085.trenn@suse.de (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Thomas Renninger Sept. 25, 2012, 3:25 p.m. UTC
ACPI: Only allow users with CAP_SYS_RAWIO rights to overwrite ACPI funcs at runtime

and tab align file_operations callbacks.

Signed-off-by: Thomas Renninger <trenn@suse.de>
---
 drivers/acpi/custom_method.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/acpi/custom_method.c b/drivers/acpi/custom_method.c
index 5d42c24..9a0294d 100644
--- a/drivers/acpi/custom_method.c
+++ b/drivers/acpi/custom_method.c
@@ -72,9 +72,15 @@  static ssize_t cm_write(struct file *file, const char __user * user_buf,
 	return count;
 }
 
+static int open_check_acc(struct inode *inode, struct file *filp)
+{
+	return capable(CAP_SYS_RAWIO) ? 0 : -EPERM;
+}
+
 static const struct file_operations cm_fops = {
-	.write = cm_write,
-	.llseek = default_llseek,
+	.write	= cm_write,
+	.llseek	= default_llseek,
+	.open	= open_check_acc,
 };
 
 static int __init acpi_custom_method_init(void)