~ubuntu-branches/ubuntu/quantal/linux-linaro-mx51/quantal

« back to all changes in this revision

Viewing changes to fs/xattr.c

  • Committer: Package Import Robot
  • Author(s): John Rigby, John Rigby
  • Date: 2011-09-26 10:44:23 UTC
  • Revision ID: package-import@ubuntu.com-20110926104423-3o58a3c1bj7x00rs
Tags: 3.0.0-1007.9
[ John Rigby ]

Enable crypto modules and remove crypto-modules from
exclude-module files
LP: #826021

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
                return 0;
47
47
 
48
48
        /*
49
 
         * The trusted.* namespace can only be accessed by a privileged user.
 
49
         * The trusted.* namespace can only be accessed by privileged users.
50
50
         */
51
 
        if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN))
52
 
                return (capable(CAP_SYS_ADMIN) ? 0 : -EPERM);
 
51
        if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN)) {
 
52
                if (!capable(CAP_SYS_ADMIN))
 
53
                        return (mask & MAY_WRITE) ? -EPERM : -ENODATA;
 
54
                return 0;
 
55
        }
53
56
 
54
 
        /* In user.* namespace, only regular files and directories can have
 
57
        /*
 
58
         * In the user.* namespace, only regular files and directories can have
55
59
         * extended attributes. For sticky directories, only the owner and
56
 
         * privileged user can write attributes.
 
60
         * privileged users can write attributes.
57
61
         */
58
62
        if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
59
63
                if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode))
60
 
                        return -EPERM;
 
64
                        return (mask & MAY_WRITE) ? -EPERM : -ENODATA;
61
65
                if (S_ISDIR(inode->i_mode) && (inode->i_mode & S_ISVTX) &&
62
66
                    (mask & MAY_WRITE) && !inode_owner_or_capable(inode))
63
67
                        return -EPERM;
87
91
{
88
92
        struct inode *inode = dentry->d_inode;
89
93
        int error = -EOPNOTSUPP;
 
94
        int issec = !strncmp(name, XATTR_SECURITY_PREFIX,
 
95
                                   XATTR_SECURITY_PREFIX_LEN);
90
96
 
 
97
        if (issec)
 
98
                inode->i_flags &= ~S_NOSEC;
91
99
        if (inode->i_op->setxattr) {
92
100
                error = inode->i_op->setxattr(dentry, name, value, size, flags);
93
101
                if (!error) {
95
103
                        security_inode_post_setxattr(dentry, name, value,
96
104
                                                     size, flags);
97
105
                }
98
 
        } else if (!strncmp(name, XATTR_SECURITY_PREFIX,
99
 
                                XATTR_SECURITY_PREFIX_LEN)) {
 
106
        } else if (issec) {
100
107
                const char *suffix = name + XATTR_SECURITY_PREFIX_LEN;
101
108
                error = security_inode_setsecurity(inode, suffix, value,
102
109
                                                   size, flags);