diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2013-02-06 04:37:39 -0500 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2013-02-13 10:28:53 -0500 |
commit | 3da46565043a3d7b9fd5c924e7de2d3e65e9d2a9 (patch) | |
tree | 71d4dade7e6b9d32d915d28a98878fb730ccd6ac /fs/cifs | |
parent | fef59fd728366aa9bf125b8859aff84fa0bd1a36 (diff) |
cifs: Modify struct smb_vol to use kuids and kgids
Add two helper functions get_option_uid and get_option_gid to handle
the work of parsing uid and gids paramaters from the command line and
making kuids and kgids out of them.
Cc: Steve French <smfrench@gmail.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Diffstat (limited to 'fs/cifs')
-rw-r--r-- | fs/cifs/cifsglob.h | 10 | ||||
-rw-r--r-- | fs/cifs/connect.c | 50 |
2 files changed, 45 insertions, 15 deletions
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 04aa74e5b348..e308e8bd0772 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h | |||
@@ -399,11 +399,11 @@ struct smb_vol { | |||
399 | char *iocharset; /* local code page for mapping to and from Unicode */ | 399 | char *iocharset; /* local code page for mapping to and from Unicode */ |
400 | char source_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* clnt nb name */ | 400 | char source_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* clnt nb name */ |
401 | char target_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* srvr nb name */ | 401 | char target_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* srvr nb name */ |
402 | uid_t cred_uid; | 402 | kuid_t cred_uid; |
403 | uid_t linux_uid; | 403 | kuid_t linux_uid; |
404 | gid_t linux_gid; | 404 | kgid_t linux_gid; |
405 | uid_t backupuid; | 405 | kuid_t backupuid; |
406 | gid_t backupgid; | 406 | kgid_t backupgid; |
407 | umode_t file_mode; | 407 | umode_t file_mode; |
408 | umode_t dir_mode; | 408 | umode_t dir_mode; |
409 | unsigned secFlg; | 409 | unsigned secFlg; |
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 541169459223..9bd13a75602d 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -987,6 +987,41 @@ static int get_option_ul(substring_t args[], unsigned long *option) | |||
987 | return rc; | 987 | return rc; |
988 | } | 988 | } |
989 | 989 | ||
990 | static int get_option_uid(substring_t args[], kuid_t *result) | ||
991 | { | ||
992 | unsigned long value; | ||
993 | kuid_t uid; | ||
994 | int rc; | ||
995 | |||
996 | rc = get_option_ul(args, &value); | ||
997 | if (rc) | ||
998 | return rc; | ||
999 | |||
1000 | uid = make_kuid(current_user_ns(), value); | ||
1001 | if (!uid_valid(uid)) | ||
1002 | return -EINVAL; | ||
1003 | |||
1004 | *result = uid; | ||
1005 | return 0; | ||
1006 | } | ||
1007 | |||
1008 | static int get_option_gid(substring_t args[], kgid_t *result) | ||
1009 | { | ||
1010 | unsigned long value; | ||
1011 | kgid_t gid; | ||
1012 | int rc; | ||
1013 | |||
1014 | rc = get_option_ul(args, &value); | ||
1015 | if (rc) | ||
1016 | return rc; | ||
1017 | |||
1018 | gid = make_kgid(current_user_ns(), value); | ||
1019 | if (!gid_valid(gid)) | ||
1020 | return -EINVAL; | ||
1021 | |||
1022 | *result = gid; | ||
1023 | return 0; | ||
1024 | } | ||
990 | 1025 | ||
991 | static int cifs_parse_security_flavors(char *value, | 1026 | static int cifs_parse_security_flavors(char *value, |
992 | struct smb_vol *vol) | 1027 | struct smb_vol *vol) |
@@ -1424,47 +1459,42 @@ cifs_parse_mount_options(const char *mountdata, const char *devname, | |||
1424 | 1459 | ||
1425 | /* Numeric Values */ | 1460 | /* Numeric Values */ |
1426 | case Opt_backupuid: | 1461 | case Opt_backupuid: |
1427 | if (get_option_ul(args, &option)) { | 1462 | if (get_option_uid(args, &vol->backupuid)) { |
1428 | cERROR(1, "%s: Invalid backupuid value", | 1463 | cERROR(1, "%s: Invalid backupuid value", |
1429 | __func__); | 1464 | __func__); |
1430 | goto cifs_parse_mount_err; | 1465 | goto cifs_parse_mount_err; |
1431 | } | 1466 | } |
1432 | vol->backupuid = option; | ||
1433 | vol->backupuid_specified = true; | 1467 | vol->backupuid_specified = true; |
1434 | break; | 1468 | break; |
1435 | case Opt_backupgid: | 1469 | case Opt_backupgid: |
1436 | if (get_option_ul(args, &option)) { | 1470 | if (get_option_gid(args, &vol->backupgid)) { |
1437 | cERROR(1, "%s: Invalid backupgid value", | 1471 | cERROR(1, "%s: Invalid backupgid value", |
1438 | __func__); | 1472 | __func__); |
1439 | goto cifs_parse_mount_err; | 1473 | goto cifs_parse_mount_err; |
1440 | } | 1474 | } |
1441 | vol->backupgid = option; | ||
1442 | vol->backupgid_specified = true; | 1475 | vol->backupgid_specified = true; |
1443 | break; | 1476 | break; |
1444 | case Opt_uid: | 1477 | case Opt_uid: |
1445 | if (get_option_ul(args, &option)) { | 1478 | if (get_option_uid(args, &vol->linux_uid)) { |
1446 | cERROR(1, "%s: Invalid uid value", | 1479 | cERROR(1, "%s: Invalid uid value", |
1447 | __func__); | 1480 | __func__); |
1448 | goto cifs_parse_mount_err; | 1481 | goto cifs_parse_mount_err; |
1449 | } | 1482 | } |
1450 | vol->linux_uid = option; | ||
1451 | uid_specified = true; | 1483 | uid_specified = true; |
1452 | break; | 1484 | break; |
1453 | case Opt_cruid: | 1485 | case Opt_cruid: |
1454 | if (get_option_ul(args, &option)) { | 1486 | if (get_option_uid(args, &vol->cred_uid)) { |
1455 | cERROR(1, "%s: Invalid cruid value", | 1487 | cERROR(1, "%s: Invalid cruid value", |
1456 | __func__); | 1488 | __func__); |
1457 | goto cifs_parse_mount_err; | 1489 | goto cifs_parse_mount_err; |
1458 | } | 1490 | } |
1459 | vol->cred_uid = option; | ||
1460 | break; | 1491 | break; |
1461 | case Opt_gid: | 1492 | case Opt_gid: |
1462 | if (get_option_ul(args, &option)) { | 1493 | if (get_option_gid(args, &vol->linux_gid)) { |
1463 | cERROR(1, "%s: Invalid gid value", | 1494 | cERROR(1, "%s: Invalid gid value", |
1464 | __func__); | 1495 | __func__); |
1465 | goto cifs_parse_mount_err; | 1496 | goto cifs_parse_mount_err; |
1466 | } | 1497 | } |
1467 | vol->linux_gid = option; | ||
1468 | gid_specified = true; | 1498 | gid_specified = true; |
1469 | break; | 1499 | break; |
1470 | case Opt_file_mode: | 1500 | case Opt_file_mode: |