Deleted Added
full compact
nfs_commonsubs.c (229802) nfs_commonsubs.c (240720)
1/*-
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Rick Macklem at The University of Guelph.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 18 unchanged lines hidden (view full) ---

27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 */
33
34#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Rick Macklem at The University of Guelph.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 18 unchanged lines hidden (view full) ---

27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 */
33
34#include <sys/cdefs.h>
35__FBSDID("$FreeBSD: head/sys/fs/nfs/nfs_commonsubs.c 229802 2012-01-08 01:54:46Z rmacklem $");
35__FBSDID("$FreeBSD: head/sys/fs/nfs/nfs_commonsubs.c 240720 2012-09-20 02:49:25Z rmacklem $");
36
37/*
38 * These functions support the macros and help fiddle mbuf chains for
39 * the nfs op functions. They do things like create the rpc header and
40 * copy data between mbuf chains and uio lists.
41 */
42#ifndef APPLEKEXT
43#include "opt_inet6.h"

--- 1352 unchanged lines hidden (view full) ---

1396 error = nfsrv_mtostr(nd, cp, j);
1397 if (error) {
1398 if (j > NFSV4_SMALLSTR)
1399 free(cp, M_NFSSTRING);
1400 goto nfsmout;
1401 }
1402 if (compare) {
1403 if (!(*retcmpp)) {
36
37/*
38 * These functions support the macros and help fiddle mbuf chains for
39 * the nfs op functions. They do things like create the rpc header and
40 * copy data between mbuf chains and uio lists.
41 */
42#ifndef APPLEKEXT
43#include "opt_inet6.h"

--- 1352 unchanged lines hidden (view full) ---

1396 error = nfsrv_mtostr(nd, cp, j);
1397 if (error) {
1398 if (j > NFSV4_SMALLSTR)
1399 free(cp, M_NFSSTRING);
1400 goto nfsmout;
1401 }
1402 if (compare) {
1403 if (!(*retcmpp)) {
1404 if (nfsv4_strtouid(cp, j, &uid, p) ||
1404 if (nfsv4_strtouid(nd, cp, j, &uid, p) ||
1405 nap->na_uid != uid)
1406 *retcmpp = NFSERR_NOTSAME;
1407 }
1408 } else if (nap != NULL) {
1405 nap->na_uid != uid)
1406 *retcmpp = NFSERR_NOTSAME;
1407 }
1408 } else if (nap != NULL) {
1409 if (nfsv4_strtouid(cp, j, &uid, p))
1409 if (nfsv4_strtouid(nd, cp, j, &uid, p))
1410 nap->na_uid = nfsrv_defaultuid;
1411 else
1412 nap->na_uid = uid;
1413 }
1414 if (j > NFSV4_SMALLSTR)
1415 free(cp, M_NFSSTRING);
1416 break;
1417 case NFSATTRBIT_OWNERGROUP:

--- 11 unchanged lines hidden (view full) ---

1429 error = nfsrv_mtostr(nd, cp, j);
1430 if (error) {
1431 if (j > NFSV4_SMALLSTR)
1432 free(cp, M_NFSSTRING);
1433 goto nfsmout;
1434 }
1435 if (compare) {
1436 if (!(*retcmpp)) {
1410 nap->na_uid = nfsrv_defaultuid;
1411 else
1412 nap->na_uid = uid;
1413 }
1414 if (j > NFSV4_SMALLSTR)
1415 free(cp, M_NFSSTRING);
1416 break;
1417 case NFSATTRBIT_OWNERGROUP:

--- 11 unchanged lines hidden (view full) ---

1429 error = nfsrv_mtostr(nd, cp, j);
1430 if (error) {
1431 if (j > NFSV4_SMALLSTR)
1432 free(cp, M_NFSSTRING);
1433 goto nfsmout;
1434 }
1435 if (compare) {
1436 if (!(*retcmpp)) {
1437 if (nfsv4_strtogid(cp, j, &gid, p) ||
1437 if (nfsv4_strtogid(nd, cp, j, &gid, p) ||
1438 nap->na_gid != gid)
1439 *retcmpp = NFSERR_NOTSAME;
1440 }
1441 } else if (nap != NULL) {
1438 nap->na_gid != gid)
1439 *retcmpp = NFSERR_NOTSAME;
1440 }
1441 } else if (nap != NULL) {
1442 if (nfsv4_strtogid(cp, j, &gid, p))
1442 if (nfsv4_strtogid(nd, cp, j, &gid, p))
1443 nap->na_gid = nfsrv_defaultgid;
1444 else
1445 nap->na_gid = gid;
1446 }
1447 if (j > NFSV4_SMALLSTR)
1448 free(cp, M_NFSSTRING);
1449 break;
1450 case NFSATTRBIT_QUOTAHARD:

--- 1138 unchanged lines hidden (view full) ---

2589 }
2590 return;
2591}
2592
2593/*
2594 * Convert a string to a uid.
2595 * If no conversion is possible return NFSERR_BADOWNER, otherwise
2596 * return 0.
1443 nap->na_gid = nfsrv_defaultgid;
1444 else
1445 nap->na_gid = gid;
1446 }
1447 if (j > NFSV4_SMALLSTR)
1448 free(cp, M_NFSSTRING);
1449 break;
1450 case NFSATTRBIT_QUOTAHARD:

--- 1138 unchanged lines hidden (view full) ---

2589 }
2590 return;
2591}
2592
2593/*
2594 * Convert a string to a uid.
2595 * If no conversion is possible return NFSERR_BADOWNER, otherwise
2596 * return 0.
2597 * If this is called from a client side mount using AUTH_SYS and the
2598 * string is made up entirely of digits, just convert the string to
2599 * a number.
2597 */
2598APPLESTATIC int
2600 */
2601APPLESTATIC int
2599nfsv4_strtouid(u_char *str, int len, uid_t *uidp, NFSPROC_T *p)
2602nfsv4_strtouid(struct nfsrv_descript *nd, u_char *str, int len, uid_t *uidp,
2603 NFSPROC_T *p)
2600{
2601 int i;
2604{
2605 int i;
2602 u_char *cp;
2606 char *cp, *endstr, *str0;
2603 struct nfsusrgrp *usrp;
2604 int cnt, ret;
2605 int error = 0;
2607 struct nfsusrgrp *usrp;
2608 int cnt, ret;
2609 int error = 0;
2610 uid_t tuid;
2606
2607 if (len == 0) {
2608 error = NFSERR_BADOWNER;
2609 goto out;
2610 }
2611
2612 if (len == 0) {
2613 error = NFSERR_BADOWNER;
2614 goto out;
2615 }
2616 /* If a string of digits and an AUTH_SYS mount, just convert it. */
2617 str0 = str;
2618 tuid = (uid_t)strtoul(str0, &endstr, 10);
2619 if ((endstr - str0) == len &&
2620 (nd->nd_flag & (ND_KERBV | ND_NFSCL)) == ND_NFSCL) {
2621 *uidp = tuid;
2622 goto out;
2623 }
2611 /*
2612 * Look for an '@'.
2613 */
2624 /*
2625 * Look for an '@'.
2626 */
2614 cp = str;
2615 for (i = 0; i < len; i++)
2616 if (*cp++ == '@')
2617 break;
2627 cp = strchr(str0, '@');
2628 if (cp != NULL)
2629 i = (int)(cp++ - str0);
2630 else
2631 i = len;
2618
2619 cnt = 0;
2620tryagain:
2621 NFSLOCKNAMEID();
2622 /*
2623 * If an '@' is found and the domain name matches, search for the name
2624 * with dns stripped off.
2625 * Mixed case alpahbetics will match for the domain name, but all

--- 152 unchanged lines hidden (view full) ---

2778 *cp-- = '0' + (tmp % 10);
2779 tmp /= 10;
2780 }
2781 return;
2782}
2783
2784/*
2785 * Convert a string to a gid.
2632
2633 cnt = 0;
2634tryagain:
2635 NFSLOCKNAMEID();
2636 /*
2637 * If an '@' is found and the domain name matches, search for the name
2638 * with dns stripped off.
2639 * Mixed case alpahbetics will match for the domain name, but all

--- 152 unchanged lines hidden (view full) ---

2792 *cp-- = '0' + (tmp % 10);
2793 tmp /= 10;
2794 }
2795 return;
2796}
2797
2798/*
2799 * Convert a string to a gid.
2800 * If no conversion is possible return NFSERR_BADOWNER, otherwise
2801 * return 0.
2802 * If this is called from a client side mount using AUTH_SYS and the
2803 * string is made up entirely of digits, just convert the string to
2804 * a number.
2786 */
2787APPLESTATIC int
2805 */
2806APPLESTATIC int
2788nfsv4_strtogid(u_char *str, int len, gid_t *gidp, NFSPROC_T *p)
2807nfsv4_strtogid(struct nfsrv_descript *nd, u_char *str, int len, gid_t *gidp,
2808 NFSPROC_T *p)
2789{
2790 int i;
2809{
2810 int i;
2791 u_char *cp;
2811 char *cp, *endstr, *str0;
2792 struct nfsusrgrp *usrp;
2793 int cnt, ret;
2794 int error = 0;
2812 struct nfsusrgrp *usrp;
2813 int cnt, ret;
2814 int error = 0;
2815 gid_t tgid;
2795
2796 if (len == 0) {
2797 error = NFSERR_BADOWNER;
2798 goto out;
2799 }
2816
2817 if (len == 0) {
2818 error = NFSERR_BADOWNER;
2819 goto out;
2820 }
2821 /* If a string of digits and an AUTH_SYS mount, just convert it. */
2822 str0 = str;
2823 tgid = (gid_t)strtoul(str0, &endstr, 10);
2824 if ((endstr - str0) == len &&
2825 (nd->nd_flag & (ND_KERBV | ND_NFSCL)) == ND_NFSCL) {
2826 *gidp = tgid;
2827 goto out;
2828 }
2800 /*
2801 * Look for an '@'.
2802 */
2829 /*
2830 * Look for an '@'.
2831 */
2803 cp = str;
2804 for (i = 0; i < len; i++)
2805 if (*cp++ == '@')
2806 break;
2832 cp = strchr(str0, '@');
2833 if (cp != NULL)
2834 i = (int)(cp++ - str0);
2835 else
2836 i = len;
2807
2808 cnt = 0;
2809tryagain:
2810 NFSLOCKNAMEID();
2811 /*
2812 * If an '@' is found and the dns name matches, search for the name
2813 * with the dns stripped off.
2814 */

--- 668 unchanged lines hidden ---
2837
2838 cnt = 0;
2839tryagain:
2840 NFSLOCKNAMEID();
2841 /*
2842 * If an '@' is found and the dns name matches, search for the name
2843 * with the dns stripped off.
2844 */

--- 668 unchanged lines hidden ---