diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2012-02-07 19:20:48 -0500 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2013-02-13 09:00:51 -0500 |
commit | a0a5386ac6400493cc2eb8b58583e56af0708730 (patch) | |
tree | 2c46bb450629c4ee3296857ae20d77d902554500 | |
parent | f74f70f8b10b435f5f20247e70d1d86b53a59685 (diff) |
afs: Support interacting with multiple user namespaces
Modify struct afs_file_status to store owner as a kuid_t and group as
a kgid_t.
In xdr_decode_AFSFetchStatus as owner is now a kuid_t and group is now
a kgid_t don't use the EXTRACT macro. Instead perform the work of
the extract macro explicitly. Read the value with ntohl and
convert it to the appropriate type with make_kuid or make_kgid.
Test if the value is different from what is stored in status and
update changed. Update the value in status.
In xdr_encode_AFS_StoreStatus call from_kuid or from_kgid as
we are computing the on the wire encoding.
Initialize uids with GLOBAL_ROOT_UID instead of 0.
Initialize gids with GLOBAL_ROOT_GID instead of 0.
Cc: David Howells <dhowells@redhat.com>
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
-rw-r--r-- | fs/afs/afs.h | 4 | ||||
-rw-r--r-- | fs/afs/fsclient.c | 14 | ||||
-rw-r--r-- | fs/afs/inode.c | 6 | ||||
-rw-r--r-- | init/Kconfig | 1 |
4 files changed, 15 insertions, 10 deletions
diff --git a/fs/afs/afs.h b/fs/afs/afs.h index 3d8fd35c0dd0..3c462ff6db63 100644 --- a/fs/afs/afs.h +++ b/fs/afs/afs.h | |||
@@ -119,8 +119,8 @@ struct afs_file_status { | |||
119 | u64 size; /* file size */ | 119 | u64 size; /* file size */ |
120 | afs_dataversion_t data_version; /* current data version */ | 120 | afs_dataversion_t data_version; /* current data version */ |
121 | u32 author; /* author ID */ | 121 | u32 author; /* author ID */ |
122 | u32 owner; /* owner ID */ | 122 | kuid_t owner; /* owner ID */ |
123 | u32 group; /* group ID */ | 123 | kgid_t group; /* group ID */ |
124 | afs_access_t caller_access; /* access rights for authenticated caller */ | 124 | afs_access_t caller_access; /* access rights for authenticated caller */ |
125 | afs_access_t anon_access; /* access rights for unauthenticated caller */ | 125 | afs_access_t anon_access; /* access rights for unauthenticated caller */ |
126 | umode_t mode; /* UNIX mode */ | 126 | umode_t mode; /* UNIX mode */ |
diff --git a/fs/afs/fsclient.c b/fs/afs/fsclient.c index b960ff05ea0b..c2e930ec2888 100644 --- a/fs/afs/fsclient.c +++ b/fs/afs/fsclient.c | |||
@@ -42,6 +42,8 @@ static void xdr_decode_AFSFetchStatus(const __be32 **_bp, | |||
42 | umode_t mode; | 42 | umode_t mode; |
43 | u64 data_version, size; | 43 | u64 data_version, size; |
44 | u32 changed = 0; /* becomes non-zero if ctime-type changes seen */ | 44 | u32 changed = 0; /* becomes non-zero if ctime-type changes seen */ |
45 | kuid_t owner; | ||
46 | kgid_t group; | ||
45 | 47 | ||
46 | #define EXTRACT(DST) \ | 48 | #define EXTRACT(DST) \ |
47 | do { \ | 49 | do { \ |
@@ -56,7 +58,9 @@ static void xdr_decode_AFSFetchStatus(const __be32 **_bp, | |||
56 | size = ntohl(*bp++); | 58 | size = ntohl(*bp++); |
57 | data_version = ntohl(*bp++); | 59 | data_version = ntohl(*bp++); |
58 | EXTRACT(status->author); | 60 | EXTRACT(status->author); |
59 | EXTRACT(status->owner); | 61 | owner = make_kuid(&init_user_ns, ntohl(*bp++)); |
62 | changed |= !uid_eq(owner, status->owner); | ||
63 | status->owner = owner; | ||
60 | EXTRACT(status->caller_access); /* call ticket dependent */ | 64 | EXTRACT(status->caller_access); /* call ticket dependent */ |
61 | EXTRACT(status->anon_access); | 65 | EXTRACT(status->anon_access); |
62 | EXTRACT(status->mode); | 66 | EXTRACT(status->mode); |
@@ -65,7 +69,9 @@ static void xdr_decode_AFSFetchStatus(const __be32 **_bp, | |||
65 | bp++; /* seg size */ | 69 | bp++; /* seg size */ |
66 | status->mtime_client = ntohl(*bp++); | 70 | status->mtime_client = ntohl(*bp++); |
67 | status->mtime_server = ntohl(*bp++); | 71 | status->mtime_server = ntohl(*bp++); |
68 | EXTRACT(status->group); | 72 | group = make_kgid(&init_user_ns, ntohl(*bp++)); |
73 | changed |= !gid_eq(group, status->group); | ||
74 | status->group = group; | ||
69 | bp++; /* sync counter */ | 75 | bp++; /* sync counter */ |
70 | data_version |= (u64) ntohl(*bp++) << 32; | 76 | data_version |= (u64) ntohl(*bp++) << 32; |
71 | EXTRACT(status->lock_count); | 77 | EXTRACT(status->lock_count); |
@@ -181,12 +187,12 @@ static void xdr_encode_AFS_StoreStatus(__be32 **_bp, struct iattr *attr) | |||
181 | 187 | ||
182 | if (attr->ia_valid & ATTR_UID) { | 188 | if (attr->ia_valid & ATTR_UID) { |
183 | mask |= AFS_SET_OWNER; | 189 | mask |= AFS_SET_OWNER; |
184 | owner = attr->ia_uid; | 190 | owner = from_kuid(&init_user_ns, attr->ia_uid); |
185 | } | 191 | } |
186 | 192 | ||
187 | if (attr->ia_valid & ATTR_GID) { | 193 | if (attr->ia_valid & ATTR_GID) { |
188 | mask |= AFS_SET_GROUP; | 194 | mask |= AFS_SET_GROUP; |
189 | group = attr->ia_gid; | 195 | group = from_kgid(&init_user_ns, attr->ia_gid); |
190 | } | 196 | } |
191 | 197 | ||
192 | if (attr->ia_valid & ATTR_MODE) { | 198 | if (attr->ia_valid & ATTR_MODE) { |
diff --git a/fs/afs/inode.c b/fs/afs/inode.c index 95cffd38239f..789bc253b5f6 100644 --- a/fs/afs/inode.c +++ b/fs/afs/inode.c | |||
@@ -69,7 +69,7 @@ static int afs_inode_map_status(struct afs_vnode *vnode, struct key *key) | |||
69 | 69 | ||
70 | set_nlink(inode, vnode->status.nlink); | 70 | set_nlink(inode, vnode->status.nlink); |
71 | inode->i_uid = vnode->status.owner; | 71 | inode->i_uid = vnode->status.owner; |
72 | inode->i_gid = 0; | 72 | inode->i_gid = GLOBAL_ROOT_GID; |
73 | inode->i_size = vnode->status.size; | 73 | inode->i_size = vnode->status.size; |
74 | inode->i_ctime.tv_sec = vnode->status.mtime_server; | 74 | inode->i_ctime.tv_sec = vnode->status.mtime_server; |
75 | inode->i_ctime.tv_nsec = 0; | 75 | inode->i_ctime.tv_nsec = 0; |
@@ -175,8 +175,8 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name, | |||
175 | inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO; | 175 | inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO; |
176 | inode->i_op = &afs_autocell_inode_operations; | 176 | inode->i_op = &afs_autocell_inode_operations; |
177 | set_nlink(inode, 2); | 177 | set_nlink(inode, 2); |
178 | inode->i_uid = 0; | 178 | inode->i_uid = GLOBAL_ROOT_UID; |
179 | inode->i_gid = 0; | 179 | inode->i_gid = GLOBAL_ROOT_GID; |
180 | inode->i_ctime.tv_sec = get_seconds(); | 180 | inode->i_ctime.tv_sec = get_seconds(); |
181 | inode->i_ctime.tv_nsec = 0; | 181 | inode->i_ctime.tv_nsec = 0; |
182 | inode->i_atime = inode->i_mtime = inode->i_ctime; | 182 | inode->i_atime = inode->i_mtime = inode->i_ctime; |
diff --git a/init/Kconfig b/init/Kconfig index 394d24f99efe..4570b02abcc5 100644 --- a/init/Kconfig +++ b/init/Kconfig | |||
@@ -1071,7 +1071,6 @@ config UIDGID_CONVERTED | |||
1071 | default y | 1071 | default y |
1072 | 1072 | ||
1073 | # Filesystems | 1073 | # Filesystems |
1074 | depends on AFS_FS = n | ||
1075 | depends on CIFS = n | 1074 | depends on CIFS = n |
1076 | depends on CODA_FS = n | 1075 | depends on CODA_FS = n |
1077 | depends on GFS2_FS = n | 1076 | depends on GFS2_FS = n |