]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
nfs3: create file tx for read on request
authorVictor Julien <victor@inliniac.net>
Wed, 14 Jun 2017 14:34:00 +0000 (16:34 +0200)
committerVictor Julien <victor@inliniac.net>
Fri, 16 Jun 2017 11:11:36 +0000 (13:11 +0200)
This is done so that we can add creds to it.

rust/src/nfs/nfs3.rs

index b6a7ba15b0af0eb6b36e1bb9c9c68d10485d751c..39af946729733c2a6defe0128538353e19a1eb0e 100644 (file)
@@ -601,6 +601,29 @@ impl NFS3State {
             SCLogDebug!("TX created: ID {} XID {} PROCEDURE {}",
                     tx.id, tx.xid, tx.procedure);
             self.transactions.push(tx);
+
+        } else if r.procedure == NFSPROC3_READ {
+
+            let found = match self.get_file_tx_by_handle(&xidmap.file_handle, STREAM_TOCLIENT) {
+                Some((_, _, _)) => true,
+                None => false,
+            };
+            if !found {
+                let (tx, _, _) = self.new_file_tx(&xidmap.file_handle, &xidmap.file_name, STREAM_TOCLIENT);
+                tx.procedure = NFSPROC3_READ;
+                tx.xid = r.hdr.xid;
+                tx.is_first = true;
+
+                tx.auth_type = r.creds_flavor;
+                match &r.creds_unix {
+                    &Some(ref u) => {
+                        tx.request_machine_name = u.machine_name_buf.to_vec();
+                        tx.request_uid = u.uid;
+                        tx.request_gid = u.gid;
+                    },
+                    _ => { },
+                }
+            }
         }
 
         self.requestmap.insert(r.hdr.xid, xidmap);