r23779: Change from v2 or later to v3 or later.
[samba.git] / source3 / modules / vfs_expand_msdfs.c
index 954f28a4118d2b99a735bc265e02e77166c1b801..bfcb18876017c6f4bae739f9fc3159812275503f 100644 (file)
@@ -5,7 +5,7 @@
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *  
  * This program is distributed in the hope that it will be useful,
@@ -23,6 +23,8 @@
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_VFS
 
+extern userdom_struct current_user_info;
+
 /**********************************************************
   Under mapfile we expect a table of the following format:
 
@@ -40,7 +42,7 @@ static BOOL read_target_host(const char *mapfile, pstring targethost)
 {
        XFILE *f;
        pstring buf;
-       char *s, *space = buf;
+       char *space = buf;
        BOOL found = False;
        
        f = x_fopen(mapfile, O_RDONLY, 0);
@@ -53,7 +55,13 @@ static BOOL read_target_host(const char *mapfile, pstring targethost)
 
        DEBUG(10, ("Scanning mapfile [%s]\n", mapfile));
 
-       while ((s=fgets_slash(buf, sizeof(buf), f)) != NULL) {
+       while (x_fgets(buf, sizeof(buf), f) != NULL) {
+
+               if ((strlen(buf) > 0) && (buf[strlen(buf)-1] == '\n'))
+                       buf[strlen(buf)-1] = '\0';
+
+               DEBUG(10, ("Scanning line [%s]\n", buf));
+
                space = strchr_m(buf, ' ');
 
                if (space == NULL) {
@@ -129,7 +137,11 @@ static BOOL expand_msdfs_target(connection_struct* conn, pstring target)
                return False;
        }
 
-       standard_sub_conn(conn, mapfilename, sizeof(mapfilename));
+       standard_sub_advanced(lp_servicename(SNUM(conn)), conn->user,
+                             conn->connectpath, conn->gid,
+                             get_current_username(),
+                             current_user_info.domain,
+                             mapfilename, sizeof(mapfilename));
 
        DEBUG(10, ("Expanded targethost to %s\n", targethost));
 
@@ -144,13 +156,12 @@ static BOOL expand_msdfs_target(connection_struct* conn, pstring target)
 }
 
 static int expand_msdfs_readlink(struct vfs_handle_struct *handle,
-                                struct connection_struct *conn,
                                 const char *path, char *buf, size_t bufsiz)
 {
        pstring target;
        int result;
 
-       result = SMB_VFS_NEXT_READLINK(handle, conn, path, target,
+       result = SMB_VFS_NEXT_READLINK(handle, path, target,
                                       sizeof(target));
 
        if (result < 0)
@@ -158,8 +169,9 @@ static int expand_msdfs_readlink(struct vfs_handle_struct *handle,
 
        target[result] = '\0';
 
-       if (strchr_m(target, '@') != NULL) {
-               if (!expand_msdfs_target(conn, target)) {
+       if ((strncmp(target, "msdfs:", strlen("msdfs:")) == 0) &&
+           (strchr_m(target, '@') != NULL)) {
+               if (!expand_msdfs_target(handle->conn, target)) {
                        errno = ENOENT;
                        return -1;
                }
@@ -177,6 +189,7 @@ static vfs_op_tuple expand_msdfs_ops[] = {
        {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP}
 };
 
+NTSTATUS vfs_expand_msdfs_init(void);
 NTSTATUS vfs_expand_msdfs_init(void)
 {
        return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "expand_msdfs",