Deleted Added
sdiff udiff text old ( 33181 ) new ( 34961 )
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

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

29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * @(#)nfs_syscalls.c 8.5 (Berkeley) 3/30/95
37 * $Id: nfs_syscalls.c,v 1.36 1998/02/09 06:10:37 eivind Exp $
38 */
39
40#include <sys/param.h>
41#include <sys/systm.h>
42#include <sys/sysproto.h>
43#include <sys/kernel.h>
44#include <sys/sysctl.h>
45#include <sys/file.h>

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

295 FREE(nuidp->nu_nam, M_SONAME);
296 }
297 nuidp->nu_flag = 0;
298 nuidp->nu_cr = nsd->nsd_cr;
299 if (nuidp->nu_cr.cr_ngroups > NGROUPS)
300 nuidp->nu_cr.cr_ngroups = NGROUPS;
301 nuidp->nu_cr.cr_ref = 1;
302 nuidp->nu_timestamp = nsd->nsd_timestamp;
303 nuidp->nu_expire = time_second + nsd->nsd_ttl;
304 /*
305 * and save the session key in nu_key.
306 */
307 bcopy(nsd->nsd_key, nuidp->nu_key,
308 sizeof (nsd->nsd_key));
309 if (nfsd->nfsd_nd->nd_nam2) {
310 struct sockaddr_in *saddr;
311

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

515 slp->ns_flag &= ~SLP_NEEDQ;
516 (void) nfs_sndlock(&slp->ns_solock,
517 (struct nfsreq *)0);
518 nfsrv_rcv(slp->ns_so, (caddr_t)slp,
519 M_WAIT);
520 nfs_sndunlock(&slp->ns_solock);
521 }
522 error = nfsrv_dorec(slp, nfsd, &nd);
523 cur_usec = nfs_curusec();
524 if (error && slp->ns_tq.lh_first &&
525 slp->ns_tq.lh_first->nd_time <= cur_usec) {
526 error = 0;
527 cacherep = RC_DOIT;
528 writes_todo = 1;
529 } else
530 writes_todo = 0;
531 nfsd->nfsd_flag |= NFSD_REQINPROG;

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

547 splx(s);
548 so = slp->ns_so;
549 sotype = so->so_type;
550 if (so->so_proto->pr_flags & PR_CONNREQUIRED)
551 solockp = &slp->ns_solock;
552 else
553 solockp = (int *)0;
554 if (nd) {
555 getmicrotime(&nd->nd_starttime);
556 if (nd->nd_nam2)
557 nd->nd_nam = nd->nd_nam2;
558 else
559 nd->nd_nam = slp->ns_nam;
560
561 /*
562 * Check to see if authorization is needed.
563 */

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

577 cacherep = RC_DROPIT;
578 } else
579 cacherep = nfsrv_getcache(nd, slp, &mreq);
580
581 /*
582 * Check for just starting up for NQNFS and send
583 * fake "try again later" replies to the NQNFS clients.
584 */
585 if (notstarted && nqnfsstarttime <= time_second) {
586 if (modify_flag) {
587 nqnfsstarttime = time_second + nqsrv_writeslack;
588 modify_flag = 0;
589 } else
590 notstarted = 0;
591 }
592 if (notstarted) {
593 if ((nd->nd_flag & ND_NQNFS) == 0)
594 cacherep = RC_DROPIT;
595 else if (nd->nd_procnum != NFSPROC_WRITE) {

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

712 FREE((caddr_t)nd, M_NFSRVDESC);
713 nd = NULL;
714 }
715
716 /*
717 * Check to see if there are outstanding writes that
718 * need to be serviced.
719 */
720 cur_usec = nfs_curusec();
721 s = splsoftclock();
722 if (slp->ns_tq.lh_first &&
723 slp->ns_tq.lh_first->nd_time <= cur_usec) {
724 cacherep = RC_DOIT;
725 writes_todo = 1;
726 } else
727 writes_todo = 0;
728 splx(s);

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

965 if (verf_len < (4 * NFSX_UNSIGNED))
966 panic("nfs_getnickauth verf too small");
967#endif
968 for (nuidp = NMUIDHASH(nmp, cred->cr_uid)->lh_first;
969 nuidp != 0; nuidp = nuidp->nu_hash.le_next) {
970 if (nuidp->nu_cr.cr_uid == cred->cr_uid)
971 break;
972 }
973 if (!nuidp || nuidp->nu_expire < time_second)
974 return (EACCES);
975
976 /*
977 * Move to the end of the lru list (end of lru == most recently used).
978 */
979 TAILQ_REMOVE(&nmp->nm_uidlruhead, nuidp, nu_lru);
980 TAILQ_INSERT_TAIL(&nmp->nm_uidlruhead, nuidp, nu_lru);
981
982 nickp = (u_long *)malloc(2 * NFSX_UNSIGNED, M_TEMP, M_WAITOK);
983 *nickp++ = txdr_unsigned(RPCAKN_NICKNAME);
984 *nickp = txdr_unsigned(nuidp->nu_nickname);
985 *auth_str = (char *)nickp;
986 *auth_len = 2 * NFSX_UNSIGNED;
987
988 /*
989 * Now we must encrypt the verifier and package it up.
990 */
991 verfp = (u_long *)verf_str;
992 *verfp++ = txdr_unsigned(RPCAKN_NICKNAME);
993 if (time_second > nuidp->nu_timestamp.tv_sec ||
994 (time_second == nuidp->nu_timestamp.tv_sec &&
995 time_second > nuidp->nu_timestamp.tv_usec))
996 getmicrotime(&nuidp->nu_timestamp);
997 else
998 nuidp->nu_timestamp.tv_usec++;
999 ktvin.tv_sec = txdr_unsigned(nuidp->nu_timestamp.tv_sec);
1000 ktvin.tv_usec = txdr_unsigned(nuidp->nu_timestamp.tv_usec);
1001
1002 /*
1003 * Now encrypt the timestamp verifier in ecb mode using the session
1004 * key.

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

1044 /*
1045 * Decrypt the timestamp in ecb mode.
1046 */
1047#ifdef NFSKERB
1048 XXX
1049#endif
1050 ktvout.tv_sec = fxdr_unsigned(long, ktvout.tv_sec);
1051 ktvout.tv_usec = fxdr_unsigned(long, ktvout.tv_usec);
1052 deltasec = time_second - ktvout.tv_sec;
1053 if (deltasec < 0)
1054 deltasec = -deltasec;
1055 /*
1056 * If ok, add it to the hash list for the mount point.
1057 */
1058 if (deltasec <= NFS_KERBCLOCKSKEW) {
1059 if (nmp->nm_numuids < nuidhash_max) {
1060 nmp->nm_numuids++;
1061 nuidp = (struct nfsuid *)
1062 malloc(sizeof (struct nfsuid), M_NFSUID,
1063 M_WAITOK);
1064 } else {
1065 nuidp = nmp->nm_uidlruhead.tqh_first;
1066 LIST_REMOVE(nuidp, nu_hash);
1067 TAILQ_REMOVE(&nmp->nm_uidlruhead, nuidp,
1068 nu_lru);
1069 }
1070 nuidp->nu_flag = 0;
1071 nuidp->nu_cr.cr_uid = cred->cr_uid;
1072 nuidp->nu_expire = time_second + NFS_KERBTTL;
1073 nuidp->nu_timestamp = ktvout;
1074 nuidp->nu_nickname = nick;
1075 bcopy(key, nuidp->nu_key, sizeof (key));
1076 TAILQ_INSERT_TAIL(&nmp->nm_uidlruhead, nuidp,
1077 nu_lru);
1078 LIST_INSERT_HEAD(NMUIDHASH(nmp, cred->cr_uid),
1079 nuidp, nu_hash);
1080 }

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

1177 rt->flag |= DRT_NQNFS;
1178 else if (nd->nd_flag & ND_NFSV3)
1179 rt->flag |= DRT_NFSV3;
1180 rt->proc = nd->nd_procnum;
1181 if (nd->nd_nam->sa_family == AF_INET)
1182 rt->ipadr = ((struct sockaddr_in *)nd->nd_nam)->sin_addr.s_addr;
1183 else
1184 rt->ipadr = INADDR_ANY;
1185 rt->resptime = nfs_curusec() - (nd->nd_starttime.tv_sec * 1000000 + nd->nd_starttime.tv_usec);
1186 getmicrotime(&rt->tstamp);
1187 nfsdrt.pos = (nfsdrt.pos + 1) % NFSRTTLOGSIZ;
1188}
1189#endif /* NFS_NOSERVER */