Commit graph

297 commits

Author SHA1 Message Date
Olga Kornievskaia
b9494c3ccc first stab at SSPI leaving gss calls in 2010-12-02 14:22:04 -05:00
Casey Bodley
32f9fa9334 replace rbtree implementation with tree.h from freebsd
added tree.h from freebsd repository and ported our name cache and client owner code

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-12-01 10:25:29 -05:00
Casey Bodley
91f584ba4b name cache: avoid copying strings for dprintf
use printf("%.*s", len, string) to print non-null-terminated strings

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-11-24 12:06:11 -05:00
Olga Kornievskaia
24c28df19d doing mount with non-fake uid gid 2010-11-08 12:54:42 -05:00
Olga Kornievskaia
a25a5221d9 adding version to the upcall
to determine that the daemon has restarted -- rather that daemon is receiving upcalls from the kernel that were processed by the old instance of the daemon -- add a version to the upcall mechanism.

when daemon starts up it generates a version number (just a timestamp). it passes this value to the driver on start up via "start_ioctl" downcall. the driver saves that value in its device extensions. it uses that value in the mount and shtudown upcalls.

when daemon replies to the mount command it again sends its version as a part of the reply. this reply is stored in driver;s netroot extensions. the driver uses netroot's value in each upcall to the daemon.

if the daemon receives an upcall for an operation where the included version does not equal to the its current version, it fails the upcall (error_code=116).

a restart of the daemon would change driver's device extension value which the driver will then use in the new mount upcalls that would establish new sessions. then the correct daemon version would be returned as a part of the mount downcalled and saved in the netroot.
2010-11-08 12:54:42 -05:00
unknown
765fb43156 [cosmetic] printing windows user name before mapping 2010-11-08 12:54:41 -05:00
Casey Bodley
a320a1b17e idmap: get uid/gid for each upcall
Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-11-08 12:54:40 -05:00
Casey Bodley
cd1251758d idmap.c for ldap caching and configuration
struct idmap_context contains configuration data (struct idmap_config), a cache for users, and a cache for groups.  idmap_context is declared in idmap.c, and only available as an opaque pointer (nfs41_idmapper) elsewhere.  similarly, Winldap.h is only included by idmap.c, and not needed elsewhere

nfs41_idmap_create() allocates the idmap_context, loads the configuration from file, and calls ldap_init().  it does not call ldap_connect(); we'll still be able to start the daemon if ldap isn't configured, or the ldap server is down.  calling ldap_connect() is optional, as any ldap operation that requires a connection will establish it internally.  this behavior, along with the LDAP_OPT_AUTO_RECONNECT option (defaults to on), means that we shouldn't have to maintain a separate connection for each thread

nfs41_idmap_*() functions return windows errors codes.  LDAP_RETCODEs are mapped to windows errors with LdapMapErrorToWin32()

the user and group caches share a common generic interface in struct idmap_cache, which uses a linked list for storage, and protects access with a SRWLOCK.  expiration of cache entries can be adjusted by the config option 'cache_ttl'

struct config_option g_options[] is a table of available config options and their default values.  this patch adds a 'ms-nfs41-idmap.conf' file with all possible options set to default values, and commented out.  the daemon expects to find this file under c:\etc\, and won't start if it can't be opened or parsed

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-11-08 12:54:40 -05:00
Casey Bodley
8321939c90 fix for warning C4204: non-constant aggregate initializer
Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-11-08 12:29:47 -05:00
Casey Bodley
38813e13d8 cosmetic: cleaning up small functions
attempted to get rid of short functions that are only called from one place

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-11-05 15:10:20 -04:00
unknown
7eae229661 setting SUPPORTS_HARD_LINKS if link_support is enabled 2010-11-04 11:51:26 -04:00
unknown
c9bbf91d4b [cosmetic] bumping debug level for remove_unsupported_attrs 2010-11-02 15:55:38 -04:00
unknown
6df50ba65c adding refcount on nfs41_root to callback server 2010-11-02 15:54:50 -04:00
unknown
7d5e6eead2 storing backpointer to nfs41_root from nfs41_client 2010-11-02 15:17:22 -04:00
unknown
7527c022a1 making upcall_marshal void 2010-11-02 14:40:52 -04:00
unknown
a57e7a78f1 removed unnecessary free_open_state() function 2010-11-02 14:31:12 -04:00
unknown
db1c02cc28 set REPARSE_POINT attr only if symlink_support attr is set 2010-11-02 14:21:06 -04:00
Casey Bodley
bcc707d3b8 ref counting for nfs41_root
very similar to the issue with nfs41_open_state, an abandoned upcall could outlive its mount. to prevent their nfs41_root from being freed, upcalls need to hold a reference until they're finished. this also keeps all of its clients/sessions/rpc connections alive

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-27 16:18:23 -04:00
Olga Kornievskaia
006bdfa47a ref counting for nfs41_open_state 2010-10-27 16:18:12 -04:00
Casey Bodley
ae4c67c21e upcall: added upcall_cleanup() to interface
added call to upcall_cleanup() after both upcall_marshall() and upcall_cancel()
individual upcall operations define their nfs41_upcall_op structs locally, instead of putting tons of function prototypes in upcall.c
made the upcall_marshall() function optional; most marshall functions are noops

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-27 16:16:17 -04:00
Casey Bodley
7e7f73766d readdir cookie is stored with nfs41_open_state
fixes a memory leak that occurs when a readdir loop doesn't complete, since the cookie was only freed on the last readdir upcall.  by storing the cookie with nfs41_open_state, we can avoid passing the cookie to the driver and back, and not worry about having to free it separately

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-27 15:25:27 -04:00
Casey Bodley
4930e7caca each mount has unique client_owner
add the netroot name to the hash for generating its client_owner

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-27 15:21:57 -04:00
Olga Kornievskaia
e51ba46d8b adding tags to compounds
contributed by Tigran
2010-10-27 15:00:12 -04:00
unknown
aa49d80acc removing libraries needed for service-version only 2010-10-20 12:21:54 -04:00
Olga Kornievskaia
a7e2d6ad2a checking functions return values
while following symlinks on open, after we break from the loop we need to respect that nfs41_lookup could have returned some kind of error value. thus only return error_reparse if nfs41_lookup returned success or file_not_found error.

similarly in after calling nfs41_symlink_follow() only set the reparse_error if function was successful.
2010-10-19 12:14:40 -04:00
unknown
bacbf060e3 making eprintfs include filename in symlink 2010-10-19 11:18:32 -04:00
Casey Bodley
f8885dbad0 warnings from WDK 6000
fixed a few cases of warning 4242: possible loss of data

wincrypt.h appears to come with windows.h in later versions of the ddk, but nfs41_client.c fails to compile in WDK 6001 without #include <wincrypt.h>

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-19 11:17:29 -04:00
unknown
caf8d3afaf fixing readlink buffer size in decode 2010-10-18 12:15:35 -04:00
Casey Bodley
64480d0aca symlink: on open for mklink, only check for FILE_EXISTS
avoid calling map_disposition_2_nfsopen() for this, because FILE_CREATE->ERROR_FILE_EXISTS is the only case we care about

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-15 17:24:10 -04:00
Casey Bodley
870b389e8f symlink: limit symlink depth to avoid following cyclical links
/* msdn: There is a maximum of 31 reparse points (and
 * therefore symbolic links) allowed in a particular path. */
#define NFS41_MAX_SYMLINK_DEPTH     31

also added checks for the return value of nfs41_symlink_target() on open/link/rename

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-15 17:24:04 -04:00
Casey Bodley
59526ba9d8 symlink: convert windows slashes when setting symlink
Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-15 14:56:13 -04:00
Casey Bodley
1ad1c0f262 symlink: rename and link handle ERROR_REPARSE
when rename or link call nfs41_lookup() for the destination directory, they need to be able to handle ERROR_REPARSE and find the real dest dir

open now does the same thing when it sees ERROR_REPARSE; previously, it was only replacing the first symlink in the path, and could require multiple reparses on a path

modified nfs41_symlink_target() to support the case where the source and destination paths are the same (used by rename/link)

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-15 14:56:06 -04:00
Casey Bodley
eb9d9bbd4c symlink: nfs41_symlink_follow() for readdir and open
added nfs41_file_info.symlink_dir to replace readdir's info.cansettime hack.  when nfs_file_info_to_attributes() finds info.type==NF4LNK, it adds the FILE_ATTRIBUTE_DIRECTORY flag if info.symlink_dir is set

renamed nfs41_symlink_follow() to nfs41_symlink_target()
generalized lookup_symlink() into nfs41_symlink_follow(), which is called by readdir and open (also avoids an extra lookup)

added queries for symlink target type when doing normal GETATTRs (getattr.c) and opens with OPEN_REPARSE_POINT set (open.c)

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-14 16:57:53 -04:00
unknown
c414d5b84e fixing license in symlink.c 2010-10-14 13:23:48 -04:00
unknown
0be2b4e495 adding symlink.c to sources 2010-10-14 12:44:20 -04:00
Casey Bodley
e27299d066 symlink: open handles embedded symlinks
returns symlink_embedded=TRUE when the symlink isn't the last component, which gets passed to RxPrepareToReparseSymbolicLink()

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-14 12:42:38 -04:00
Casey Bodley
a92fb8930e symlink: lookup handles ERR_SYMLINK
modified nfs41_lookup() to handle NFS4ERR_SYMLINK by setting parent=symlink and returning ERROR_REPARSE

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-14 12:42:38 -04:00
Casey Bodley
5748d17934 cosmetic: map_lookup_error()
Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-14 12:42:37 -04:00
Casey Bodley
30cc2e1d32 symlink: readdir and directory symlinks
windows differentiates between directory and file symlinks because a file can have both FILE_ATTRIBUTE_DIRECTORY and FILE_ATTRIBUTE_REPARSE_POINT flags.  nfs can only be one of NF4REG/DIR/LNK, so we have to do a readlink and look up the target file for symlinks to know whether or not to set the directory attribute flag.  this is done recursively when we encounter links to links

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-14 12:42:37 -04:00
Casey Bodley
ccdaa169eb symlink: handle_open() detects symlink creation
added check in handle_open() to avoid calling CREATE/OPEN when we're creating a symlink:

if (args->disposition == FILE_CREATE &&
    args->access_mask == (FILE_WRITE_ATTRIBUTES | SYNCHRONIZE | DELETE) &&
    args->access_mode == 0 &&
    args->create_opts & FILE_OPEN_REPARSE_POINT)

these are the open arguments we get from the CreateSymbolicLink() syscall.  by avoiding the call to CREATE/OPEN on handle_open(), we save ourselves from having to REMOVE the file before creating the symlink

added a check to handle_symlink() in case the file was actually created on open (an application could open the file with different arguments, and send the FSCTL_SET_REPARSE_POINT manually), and removes the file first

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-14 12:42:36 -04:00
Casey Bodley
62fa6176be symlink: FSCTL_SET_REPARSE_POINT
driver handles FSCTL_SET_REPARSE_POINT by sending a symlink set upcall
daemon handles symlink set upcall by calling nfs41_create()

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-14 12:42:36 -04:00
Casey Bodley
8c4c98b669 symlink: nfs41_create() can create symlinks
added optional symlink argument to nfs41_create(), used when type is NF4LNK
changed createttype4.u.lnk.linkdata from char[] to const char* and updated encoding in nfs41_xdr.c

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-14 12:42:35 -04:00
Casey Bodley
08c2618551 symlink: FSCTL_GET_REPARSE_POINT
driver handles FSCTL_GET_REPARSE_POINT by sending a symlink query upcall
daemon handles symlink query upcall by calling nfs41_readlink()

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-14 12:42:34 -04:00
Casey Bodley
8ea0ca1893 symlink: generalized follow_link()
no longer depends on nfs41_open_state or open_upcall_args
renamed to nfs41_symlink_follow() and added prototype to nfs41_ops.h

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-14 12:42:34 -04:00
Casey Bodley
dd48ca17c3 symlink: moved follow_link() to symlink.c [cosmetic]
Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-14 12:42:33 -04:00
Casey Bodley
0db42ed126 symlink: daemon parses SYMLINK upcall
added symlink.c for parse_symlink() and marshall_symlink()

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-14 12:42:33 -04:00
Casey Bodley
b51bd2f9d1 symlink: set reparse tag for symlinks
getattr upcall for FileAttributeTagInformation sets ReparseTag=IO_REPARSE_TAG_SYMLINK

readdir upcall sets EaSize=IO_REPARSE_TAG_SYMLINK; this makes the 'dir' command show files as <SYMLINK>, and causes a FSCTL_GET_REPARSE_POINT to query the symlink target

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
2010-10-14 12:42:32 -04:00
unknown
bc0b161fc6 STANDALONE_NFSD enabled 2010-10-14 11:45:51 -04:00
U-fast\aglo
f01f1304da bumping seq if decoded successfully
before, we would not bump the sequence if we couldn't decode an
operation in the received compound.
2010-10-13 14:46:25 -04:00
U-fast\aglo
cf75520410 cb_args should be allocated
when we fork a thread to handle the callback, the arguments we got from
parsing the callback operations in the callback thread are on the stack.
we need to allocate memory for same-size data structure and copy them,
not just copy the pointer.
2010-10-13 14:46:02 -04:00