Commit Graph

494 Commits (4cd723fb7a55360e40e7b0a78f0fd67af0d9d975)

Author SHA1 Message Date
Kevin Vigor 4cd723fb7a Fix crash on timed out mount-nfs calls.
If wait_for_nfs_reply() times out, nfs_mount can return with RPCs
still pending. In that case when the RPCs complete (perhaps because
someone calls destroy_context()), the callbacks run, and private_data
is pointing at what was the stack-allocated cb_data structure. Stack
smashing and segfaulty fun ensue.

Fix by ensuring no RPCs are pending before returning from nfs_mount()
by disconnecting on errors.
2017-05-11 15:19:01 -06:00
Ronnie Sahlberg 14adfbfc4b Merge pull request #211 from earlchew/issues-210
Check result of FSINFO before using result in nfs_mount_10_cb()
2017-05-09 22:26:23 -07:00
Ronnie Sahlberg d8d9e5556b Merge pull request #214 from earlchew/issues-206-01
Return an error if either readmax or writemax are less than NFSMAXDATA2
2017-05-09 22:07:18 -07:00
Earl Chew 2f041424d5 Return an error if either readmax or writemax are less than NFSMAXDATA2
Signed-off-by: Earl Chew <earl_chew@yahoo.com>
2017-05-09 21:55:03 -07:00
Earl Chew 63d6679132 Check result of FSINFO before using result in nfs_mount_10_cb()
Signed-off-by: Earl Chew <earl_chew@yahoo.com>
2017-05-09 21:35:30 -07:00
Ronnie Sahlberg bf7d983812 Merge pull request #208 from earlchew/issues-200
Latch error return from nfs_mount_8_cb()
2017-05-09 21:29:22 -07:00
Earl Chew 6e99d36587 Latch error return from nfs_mount_8_cb()
Signed-off-by: Earl Chew <earl_chew@yahoo.com>
2017-05-09 21:22:46 -07:00
Earl Chew c7995b4fec Revert "Provide error return from nfs_mount_8_cb()"
This reverts commit a4de2ec926.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>
2017-05-09 21:22:06 -07:00
Ronnie Sahlberg 13c253673b We do not need an async version of readlink2
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-05-09 14:56:44 -07:00
Ronnie Sahlberg 973d368867 Merge pull request #194 from earlchew/issues-187
nfs_readlink2: Return symlink without incurring ENAMETOOLONG
2017-05-09 14:55:27 -07:00
Ronnie Sahlberg 519686356c Export the nfs_readlink2[_async] symbols from the win32/64 DLL
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-05-09 14:53:12 -07:00
Ronnie Sahlberg ebd98bf966 Merge branch 'master' into issues-199 2017-05-09 14:49:58 -07:00
Ronnie Sahlberg 36d5cf8a1c Merge pull request #204 from earlchew/issues-200
Provide error return from nfs_mount_8_cb()
2017-05-09 14:33:03 -07:00
Ronnie Sahlberg 5b28ab5d53 Include sys/sysmacros.h on platforms that have it
This addresses issue 202

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-05-09 14:30:14 -07:00
Earl Chew a4de2ec926 Provide error return from nfs_mount_8_cb()
Signed-off-by: Earl Chew <earl_chew@yahoo.com>
2017-05-09 07:15:11 -07:00
Earl Chew be6fd2b098 Free inbuf in rpc_destroy_context()
Signed-off-by: Earl Chew <earl_chew@yahoo.com>
2017-05-09 07:10:23 -07:00
Earl Chew e74846219a nfs_readlink2: Return symlink without incurring ENAMETOOLONG
Signed-off-by: Earl Chew <earl_chew@yahoo.com>
2017-05-08 21:56:50 -07:00
Earl Chew e788078e20 Revert "nfs_readlink2: Return symlink without incurring ENAMETOOLONG"
This reverts commit 1af36b4c77.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>
2017-05-08 21:55:54 -07:00
Ronnie Sahlberg ea3ee73e23 Merge pull request #192 from earlchew/issue-191
nfs_open: Support O_NOFOLLOW
2017-05-08 21:00:55 -07:00
Ronnie Sahlberg 15c7b4c33a Add mkdir2() to the symbols we export for win32/64
and will at some point restrict export to for .so libraries as well.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-05-08 20:54:36 -07:00
Ronnie Sahlberg 2589086ce5 Merge pull request #193 from earlchew/issues-189
nfs_mkdir2: Include permissions when creating a new directory
2017-05-08 20:52:55 -07:00
Ronnie Sahlberg 3ad4ac1b1e Merge branch 'master' of github.com:sahlberg/libnfs 2017-05-08 18:40:10 -07:00
Ronnie Sahlberg b5c5d5901e Add support for rpc timeouts to the async interface
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-05-08 18:38:42 -07:00
Ronnie Sahlberg 58ee12fcc7 Merge pull request #198 from earlchew/issues-197
Release callback data on nfs_create_2_cb() failure
2017-05-08 15:55:01 -07:00
Earl Chew b356c06eca Release callback data on nfs_create_2_cb() failure
Signed-off-by: Earl Chew <earl_chew@yahoo.com>
2017-05-08 15:44:48 -07:00
Earl Chew 1af36b4c77 nfs_readlink2: Return symlink without incurring ENAMETOOLONG
Signed-off-by: Earl Chew <earl_chew@yahoo.com>
2017-05-05 07:57:28 -07:00
Earl Chew adcfda60fa nfs_mkdir2: Include permissions when creating a new directory
Signed-off-by: Earl Chew <earl_chew@yahoo.com>
2017-05-05 07:55:09 -07:00
Earl Chew 9bd2ceddd3 nfs_open: Support O_NOFOLLOW
Signed-off-by: Earl Chew <earl_chew@yahoo.com>
2017-05-05 07:50:35 -07:00
Ronnie Sahlberg 64f7e73ded Fix bug in nfs_link when using the wrong(invalid) handle when dropping cache
This should be a fix for issue 186

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-05-02 17:50:47 -07:00
Ronnie Sahlberg 24064e96d2 Add example util for nfs_link()
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-05-02 17:36:27 -07:00
Ronnie Sahlberg a523f84353 Clamp read/write max size for servers that accept huge PDUs
Clamp the max read write size we handle to NFS_MAX_XFER_SIZE for servers
that advertize very large PDU support instead of erroring out.

Fix for issue #188

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-05-01 20:37:35 -07:00
Kevin Vigor 9e2dc9795a Make nfs_close_async call flush on the file handle before disposing of it. 2017-04-03 14:30:03 -06:00
Max Kellermann 43feceea8d don't call rpc_free_pdu() after rpc_queue_pdu() failure
rpc_queue_pdu() already calls rpc_free_pdu() in its failure code
path.  Doing that again would constitute a double free bug.
2017-03-08 14:29:06 +01:00
Ronnie Sahlberg 70df81c16a Merge pull request #173 from rosslagerwall/reconnect-retries
socket: Limit reconnect retries to 10
2017-03-02 17:07:13 -08:00
Daniel Abrecht 7882711c8c Fix crosscompile with *-w64-mingw32-gcc 2017-02-26 18:14:30 +00:00
Ross Lagerwall 08e1cc2f4d socket: Limit reconnect retries to 10
Limit the number of retries when autoreconnecting (to an arbitrary 10)
and return an error to the application if this limit is reached.
Without this, libnfs retries indefinitely and consumes 100% CPU.

See also: https://bugzilla.gnome.org/show_bug.cgi?id=762544

Signed-off-by: Ross Lagerwall <rosslagerwall@gmail.com>
2017-02-26 09:36:09 +00:00
Ronnie Sahlberg 2e0a67fcb9 Merge branch 'master' of github.com:sahlberg/libnfs 2017-02-19 09:15:43 -08:00
Ronnie Sahlberg 6923a99262 Fix memory leak of nested mount list
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-02-19 09:14:29 -08:00
Max Kellermann 038af3a5ff socket: pass u_long* to ioctlsocket()
See https://msdn.microsoft.com/en-us/library/windows/desktop/ms738573(v=vs.85).aspx
2017-02-10 23:43:21 +01:00
Max Kellermann 03f3cdf9a9 lib/pdu: remove unnecessary NULL check before free()
free(NULL) is explicitly legal.
2017-02-09 12:53:45 +01:00
Max Kellermann 2b3c164db2 lib/pdu: don't clear pointers in rpc_free_pdu()
Pointless, because the containing object is going to be freed.
2017-02-09 12:53:45 +01:00
Max Kellermann 2f703bd84d lib/pdu: fix memory leaks in rpc_allocate_*()
All error code paths must contain cleanup for all allocations until
that point in the function.  Yay for plain C.
2017-02-09 12:52:22 +01:00
Ronnie Sahlberg 906d09f32f Merge pull request #168 from MaxKellermann/cloexec
Use SOCK_CLOEXEC
2017-02-08 17:28:41 -08:00
Max Kellermann 31cb099f50 init: remove pdu from list before invoking callback
If the callback does anything fishy that modifies the linked list,
libnfs may crash after returning.  So doing any pending list removals
before invoking the callbacks is safer.
2017-02-08 12:14:52 +01:00
Max Kellermann 26d90c0663 lib/socket: use SOCK_CLOEXEC in create_socket() 2017-02-08 11:53:00 +01:00
Max Kellermann 46448bccb4 lib/socket: add function create_socket()
Prepare for SOCK_CLOEXEC support.
2017-02-08 11:52:32 +01:00
Ronnie Sahlberg 1d6600652c Merge pull request #167 from MaxKellermann/static
init: move static to beginning of declaration
2017-02-04 17:34:44 -08:00
Max Kellermann ddc37a365e init: move static to beginning of declaration
Fixes gcc's -Wold-style-declaration.

Signed-off-by: Max Kellermann <max.kellermann@gmail.com>
2017-02-03 19:56:35 +01:00
Max Kellermann 03ac15de5e Allow passing void* buffers, and make write buffers const
Enables callers to pass any opaque data chunk without having to cast
it explicitly.

A write never modifies the source buffer, and thus the pointer should
be const.

Signed-off-by: Max Kellermann <max.kellermann@gmail.com>
2017-02-03 19:42:12 +01:00
Ronnie Sahlberg d6a21b2bda Make rpc_set{g|u}id() public
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-01-30 17:47:18 -08:00