diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2012-02-07 19:29:36 -0500 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2012-09-21 06:13:15 -0400 |
commit | b29f7751c9a880e842e48f421daf313b997ddd65 (patch) | |
tree | 272336a7eb1374a68999551f26bdb4efe60fa054 /fs/ntfs | |
parent | 305d3d0dbc22aa62fa4d8b9224826fd8c7104bc5 (diff) |
userns: Convert ntfs to use kuid and kgid where appropriate
Cc: Anton Altaparmakov <anton@tuxera.com>
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Diffstat (limited to 'fs/ntfs')
-rw-r--r-- | fs/ntfs/inode.c | 7 | ||||
-rw-r--r-- | fs/ntfs/super.c | 39 | ||||
-rw-r--r-- | fs/ntfs/volume.h | 5 |
3 files changed, 39 insertions, 12 deletions
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c index c6dbd3db6ca8..1d27331e6fc9 100644 --- a/fs/ntfs/inode.c +++ b/fs/ntfs/inode.c | |||
@@ -2124,7 +2124,8 @@ int ntfs_read_inode_mount(struct inode *vi) | |||
2124 | * ntfs_read_inode() will have set up the default ones. | 2124 | * ntfs_read_inode() will have set up the default ones. |
2125 | */ | 2125 | */ |
2126 | /* Set uid and gid to root. */ | 2126 | /* Set uid and gid to root. */ |
2127 | vi->i_uid = vi->i_gid = 0; | 2127 | vi->i_uid = GLOBAL_ROOT_UID; |
2128 | vi->i_gid = GLOBAL_ROOT_GID; | ||
2128 | /* Regular file. No access for anyone. */ | 2129 | /* Regular file. No access for anyone. */ |
2129 | vi->i_mode = S_IFREG; | 2130 | vi->i_mode = S_IFREG; |
2130 | /* No VFS initiated operations allowed for $MFT. */ | 2131 | /* No VFS initiated operations allowed for $MFT. */ |
@@ -2312,8 +2313,8 @@ int ntfs_show_options(struct seq_file *sf, struct dentry *root) | |||
2312 | ntfs_volume *vol = NTFS_SB(root->d_sb); | 2313 | ntfs_volume *vol = NTFS_SB(root->d_sb); |
2313 | int i; | 2314 | int i; |
2314 | 2315 | ||
2315 | seq_printf(sf, ",uid=%i", vol->uid); | 2316 | seq_printf(sf, ",uid=%i", from_kuid_munged(&init_user_ns, vol->uid)); |
2316 | seq_printf(sf, ",gid=%i", vol->gid); | 2317 | seq_printf(sf, ",gid=%i", from_kgid_munged(&init_user_ns, vol->gid)); |
2317 | if (vol->fmask == vol->dmask) | 2318 | if (vol->fmask == vol->dmask) |
2318 | seq_printf(sf, ",umask=0%o", vol->fmask); | 2319 | seq_printf(sf, ",umask=0%o", vol->fmask); |
2319 | else { | 2320 | else { |
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c index 2bc149d6a784..da01c165067d 100644 --- a/fs/ntfs/super.c +++ b/fs/ntfs/super.c | |||
@@ -102,8 +102,8 @@ static bool parse_options(ntfs_volume *vol, char *opt) | |||
102 | char *p, *v, *ov; | 102 | char *p, *v, *ov; |
103 | static char *utf8 = "utf8"; | 103 | static char *utf8 = "utf8"; |
104 | int errors = 0, sloppy = 0; | 104 | int errors = 0, sloppy = 0; |
105 | uid_t uid = (uid_t)-1; | 105 | kuid_t uid = INVALID_UID; |
106 | gid_t gid = (gid_t)-1; | 106 | kgid_t gid = INVALID_GID; |
107 | umode_t fmask = (umode_t)-1, dmask = (umode_t)-1; | 107 | umode_t fmask = (umode_t)-1, dmask = (umode_t)-1; |
108 | int mft_zone_multiplier = -1, on_errors = -1; | 108 | int mft_zone_multiplier = -1, on_errors = -1; |
109 | int show_sys_files = -1, case_sensitive = -1, disable_sparse = -1; | 109 | int show_sys_files = -1, case_sensitive = -1, disable_sparse = -1; |
@@ -128,6 +128,30 @@ static bool parse_options(ntfs_volume *vol, char *opt) | |||
128 | if (*v) \ | 128 | if (*v) \ |
129 | goto needs_val; \ | 129 | goto needs_val; \ |
130 | } | 130 | } |
131 | #define NTFS_GETOPT_UID(option, variable) \ | ||
132 | if (!strcmp(p, option)) { \ | ||
133 | uid_t uid_value; \ | ||
134 | if (!v || !*v) \ | ||
135 | goto needs_arg; \ | ||
136 | uid_value = simple_strtoul(ov = v, &v, 0); \ | ||
137 | if (*v) \ | ||
138 | goto needs_val; \ | ||
139 | variable = make_kuid(current_user_ns(), uid_value); \ | ||
140 | if (!uid_valid(variable)) \ | ||
141 | goto needs_val; \ | ||
142 | } | ||
143 | #define NTFS_GETOPT_GID(option, variable) \ | ||
144 | if (!strcmp(p, option)) { \ | ||
145 | gid_t gid_value; \ | ||
146 | if (!v || !*v) \ | ||
147 | goto needs_arg; \ | ||
148 | gid_value = simple_strtoul(ov = v, &v, 0); \ | ||
149 | if (*v) \ | ||
150 | goto needs_val; \ | ||
151 | variable = make_kgid(current_user_ns(), gid_value); \ | ||
152 | if (!gid_valid(variable)) \ | ||
153 | goto needs_val; \ | ||
154 | } | ||
131 | #define NTFS_GETOPT_OCTAL(option, variable) \ | 155 | #define NTFS_GETOPT_OCTAL(option, variable) \ |
132 | if (!strcmp(p, option)) { \ | 156 | if (!strcmp(p, option)) { \ |
133 | if (!v || !*v) \ | 157 | if (!v || !*v) \ |
@@ -165,8 +189,8 @@ static bool parse_options(ntfs_volume *vol, char *opt) | |||
165 | while ((p = strsep(&opt, ","))) { | 189 | while ((p = strsep(&opt, ","))) { |
166 | if ((v = strchr(p, '='))) | 190 | if ((v = strchr(p, '='))) |
167 | *v++ = 0; | 191 | *v++ = 0; |
168 | NTFS_GETOPT("uid", uid) | 192 | NTFS_GETOPT_UID("uid", uid) |
169 | else NTFS_GETOPT("gid", gid) | 193 | else NTFS_GETOPT_GID("gid", gid) |
170 | else NTFS_GETOPT_OCTAL("umask", fmask = dmask) | 194 | else NTFS_GETOPT_OCTAL("umask", fmask = dmask) |
171 | else NTFS_GETOPT_OCTAL("fmask", fmask) | 195 | else NTFS_GETOPT_OCTAL("fmask", fmask) |
172 | else NTFS_GETOPT_OCTAL("dmask", dmask) | 196 | else NTFS_GETOPT_OCTAL("dmask", dmask) |
@@ -283,9 +307,9 @@ no_mount_options: | |||
283 | vol->on_errors = on_errors; | 307 | vol->on_errors = on_errors; |
284 | if (!vol->on_errors || vol->on_errors == ON_ERRORS_RECOVER) | 308 | if (!vol->on_errors || vol->on_errors == ON_ERRORS_RECOVER) |
285 | vol->on_errors |= ON_ERRORS_CONTINUE; | 309 | vol->on_errors |= ON_ERRORS_CONTINUE; |
286 | if (uid != (uid_t)-1) | 310 | if (uid_valid(uid)) |
287 | vol->uid = uid; | 311 | vol->uid = uid; |
288 | if (gid != (gid_t)-1) | 312 | if (gid_valid(gid)) |
289 | vol->gid = gid; | 313 | vol->gid = gid; |
290 | if (fmask != (umode_t)-1) | 314 | if (fmask != (umode_t)-1) |
291 | vol->fmask = fmask; | 315 | vol->fmask = fmask; |
@@ -1023,7 +1047,8 @@ static bool load_and_init_mft_mirror(ntfs_volume *vol) | |||
1023 | * ntfs_read_inode() will have set up the default ones. | 1047 | * ntfs_read_inode() will have set up the default ones. |
1024 | */ | 1048 | */ |
1025 | /* Set uid and gid to root. */ | 1049 | /* Set uid and gid to root. */ |
1026 | tmp_ino->i_uid = tmp_ino->i_gid = 0; | 1050 | tmp_ino->i_uid = GLOBAL_ROOT_UID; |
1051 | tmp_ino->i_gid = GLOBAL_ROOT_GID; | ||
1027 | /* Regular file. No access for anyone. */ | 1052 | /* Regular file. No access for anyone. */ |
1028 | tmp_ino->i_mode = S_IFREG; | 1053 | tmp_ino->i_mode = S_IFREG; |
1029 | /* No VFS initiated operations allowed for $MFTMirr. */ | 1054 | /* No VFS initiated operations allowed for $MFTMirr. */ |
diff --git a/fs/ntfs/volume.h b/fs/ntfs/volume.h index 15e3ba8d521a..4f579b02bc76 100644 --- a/fs/ntfs/volume.h +++ b/fs/ntfs/volume.h | |||
@@ -25,6 +25,7 @@ | |||
25 | #define _LINUX_NTFS_VOLUME_H | 25 | #define _LINUX_NTFS_VOLUME_H |
26 | 26 | ||
27 | #include <linux/rwsem.h> | 27 | #include <linux/rwsem.h> |
28 | #include <linux/uidgid.h> | ||
28 | 29 | ||
29 | #include "types.h" | 30 | #include "types.h" |
30 | #include "layout.h" | 31 | #include "layout.h" |
@@ -46,8 +47,8 @@ typedef struct { | |||
46 | sized blocks on the device. */ | 47 | sized blocks on the device. */ |
47 | /* Configuration provided by user at mount time. */ | 48 | /* Configuration provided by user at mount time. */ |
48 | unsigned long flags; /* Miscellaneous flags, see below. */ | 49 | unsigned long flags; /* Miscellaneous flags, see below. */ |
49 | uid_t uid; /* uid that files will be mounted as. */ | 50 | kuid_t uid; /* uid that files will be mounted as. */ |
50 | gid_t gid; /* gid that files will be mounted as. */ | 51 | kgid_t gid; /* gid that files will be mounted as. */ |
51 | umode_t fmask; /* The mask for file permissions. */ | 52 | umode_t fmask; /* The mask for file permissions. */ |
52 | umode_t dmask; /* The mask for directory | 53 | umode_t dmask; /* The mask for directory |
53 | permissions. */ | 54 | permissions. */ |