aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/connect.c
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2013-02-06 04:37:39 -0500
committerEric W. Biederman <ebiederm@xmission.com>2013-02-13 10:28:53 -0500
commit3da46565043a3d7b9fd5c924e7de2d3e65e9d2a9 (patch)
tree71d4dade7e6b9d32d915d28a98878fb730ccd6ac /fs/cifs/connect.c
parentfef59fd728366aa9bf125b8859aff84fa0bd1a36 (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/connect.c')
-rw-r--r--fs/cifs/connect.c50
1 files changed, 40 insertions, 10 deletions
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
990static 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
1008static 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
991static int cifs_parse_security_flavors(char *value, 1026static 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: