Smack: fix for /smack/access output, use string instead of byte
authorJarkko Sakkinen <jarkko.sakkinen@intel.com>
Mon, 10 Oct 2011 11:29:28 +0000 (14:29 +0300)
committerCasey Schaufler <cschaufler@cschaufler-intel.(none)>
Wed, 12 Oct 2011 21:30:07 +0000 (14:30 -0700)
Small fix for the output of access SmackFS file. Use string
is instead of byte. Makes it easier to extend API if it is
needed.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@intel.com>
security/smack/smackfs.c

index 54f6e18dea2f4112c2eedd92a73c70466197fb03..5498c4a2d1aec84c386bd8272ea75d4224951d82 100644 (file)
@@ -1497,6 +1497,7 @@ static ssize_t smk_write_access(struct file *file, const char __user *buf,
 {
        struct smack_rule rule;
        char *data;
+       int res;
 
        if (!capable(CAP_MAC_ADMIN))
                return -EPERM;
@@ -1508,8 +1509,10 @@ static ssize_t smk_write_access(struct file *file, const char __user *buf,
        if (count < SMK_LOADLEN || smk_parse_rule(data, &rule))
                return -EINVAL;
 
-       data[0] = smk_access(rule.smk_subject, rule.smk_object,
-                            rule.smk_access, NULL) == 0;
+       res = smk_access(rule.smk_subject, rule.smk_object, rule.smk_access,
+                         NULL);
+       data[0] = res == 0 ? '1' : '0';
+       data[1] = '\0';
 
        simple_transaction_set(file, 1);
        return SMK_LOADLEN;