s3: Use reparse point style symlinks
authorVolker Lendecke <vl@samba.org>
Thu, 23 Jun 2011 14:54:50 +0000 (16:54 +0200)
committerVolker Lendecke <vl@samba.org>
Fri, 24 Jun 2011 19:24:17 +0000 (21:24 +0200)
source3/client/client.c

index 79b57991353f4df4e5372ec35ccdafb4bfc8ea27..15c5e9cc94abc920a23a9b357812eb28e27a9d26 100644 (file)
@@ -36,6 +36,7 @@
 #include "libsmb/clirap.h"
 #include "trans2.h"
 #include "libsmb/nmblib.h"
+#include "include/ntioctl.h"
 
 #ifndef REGISTER
 #define REGISTER 0
@@ -3014,26 +3015,25 @@ static int cmd_symlink(void)
        /* Oldname (link target) must be an untouched blob. */
        oldname = buf;
 
-       newname = talloc_asprintf(ctx,
-                       "%s%s",
-                       client_get_cur_dir(),
-                       buf2);
-       if (!newname) {
-               return 1;
-       }
-
-       /* New name must be present in share namespace. */
-       if (!cli_resolve_path(ctx, "", auth_info, cli, newname, &newcli, &newname)) {
-               d_printf("link %s: %s\n", oldname, cli_errstr(cli));
-               return 1;
-       }
-
-       if (!SERVER_HAS_UNIX_CIFS(newcli)) {
-               d_printf("Server doesn't support UNIX CIFS calls.\n");
-               return 1;
+       if (SERVER_HAS_UNIX_CIFS(cli)) {
+               newname = talloc_asprintf(ctx, "%s%s", client_get_cur_dir(),
+                                         buf2);
+               if (!newname) {
+                       return 1;
+               }
+               /* New name must be present in share namespace. */
+               if (!cli_resolve_path(ctx, "", auth_info, cli, newname,
+                                     &newcli, &newname)) {
+                       d_printf("link %s: %s\n", oldname, cli_errstr(cli));
+                       return 1;
+               }
+               status = cli_posix_symlink(newcli, oldname, newname);
+       } else {
+               status = cli_symlink(
+                       cli, oldname, buf2,
+                       buf2[0] == '\\' ? 0 : SYMLINK_FLAG_RELATIVE);
        }
 
-       status = cli_posix_symlink(newcli, oldname, newname);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("%s symlinking files (%s -> %s)\n",
                         nt_errstr(status), newname, newname);