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.35 1998/02/06 12:13:57 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.tv_sec + 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 = (u_quad_t)time.tv_sec * 1000000 +
524 (u_quad_t)time.tv_usec;
525 if (error && slp->ns_tq.lh_first &&
526 slp->ns_tq.lh_first->nd_time <= cur_usec) {
527 error = 0;
528 cacherep = RC_DOIT;
529 writes_todo = 1;
530 } else
531 writes_todo = 0;
532 nfsd->nfsd_flag |= NFSD_REQINPROG;

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

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

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

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

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

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

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

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

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

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

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

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