Deleted Added
sdiff udiff text old ( 229802 ) new ( 240720 )
full compact
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 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)) {
1404 if (nfsv4_strtouid(nd, cp, j, &uid, p) ||
1405 nap->na_uid != uid)
1406 *retcmpp = NFSERR_NOTSAME;
1407 }
1408 } else if (nap != NULL) {
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)) {
1437 if (nfsv4_strtogid(nd, cp, j, &gid, p) ||
1438 nap->na_gid != gid)
1439 *retcmpp = NFSERR_NOTSAME;
1440 }
1441 } else if (nap != NULL) {
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.
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.
2600 */
2601APPLESTATIC int
2602nfsv4_strtouid(struct nfsrv_descript *nd, u_char *str, int len, uid_t *uidp,
2603 NFSPROC_T *p)
2604{
2605 int i;
2606 char *cp, *endstr, *str0;
2607 struct nfsusrgrp *usrp;
2608 int cnt, ret;
2609 int error = 0;
2610 uid_t tuid;
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 }
2624 /*
2625 * Look for an '@'.
2626 */
2627 cp = strchr(str0, '@');
2628 if (cp != NULL)
2629 i = (int)(cp++ - str0);
2630 else
2631 i = len;
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.
2805 */
2806APPLESTATIC int
2807nfsv4_strtogid(struct nfsrv_descript *nd, u_char *str, int len, gid_t *gidp,
2808 NFSPROC_T *p)
2809{
2810 int i;
2811 char *cp, *endstr, *str0;
2812 struct nfsusrgrp *usrp;
2813 int cnt, ret;
2814 int error = 0;
2815 gid_t tgid;
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 }
2829 /*
2830 * Look for an '@'.
2831 */
2832 cp = strchr(str0, '@');
2833 if (cp != NULL)
2834 i = (int)(cp++ - str0);
2835 else
2836 i = len;
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 ---