diff options
author | Jeremy Allison <jra@samba.org> | 2009-05-27 22:02:20 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2009-05-27 22:02:20 -0700 |
commit | bd1194810787901c5caa08961f97fecbcbd01978 (patch) | |
tree | 6a87f85a91457a2760038bf3b940a2d3048fe676 | |
parent | bccc7ee2c6456cdab08884b826ed5ddc2faf2a54 (diff) | |
download | samba-bd1194810787901c5caa08961f97fecbcbd01978.tar.gz samba-bd1194810787901c5caa08961f97fecbcbd01978.tar.bz2 samba-bd1194810787901c5caa08961f97fecbcbd01978.zip |
Add a smbclient "readlink" command and add docs for it.
Jeremy.
-rw-r--r-- | docs-xml/manpages-3/smbclient.1.xml | 8 | ||||
-rw-r--r-- | source3/client/client.c | 49 |
2 files changed, 57 insertions, 0 deletions
diff --git a/docs-xml/manpages-3/smbclient.1.xml b/docs-xml/manpages-3/smbclient.1.xml index 7785d2c093..9840414e44 100644 --- a/docs-xml/manpages-3/smbclient.1.xml +++ b/docs-xml/manpages-3/smbclient.1.xml @@ -916,6 +916,14 @@ </varlistentry> <varlistentry> + <term>readlink symlinkname</term> + <listitem><para>This command depends on the server supporting the CIFS + UNIX extensions and will fail if the server does not. Print + the value of the symlink "symlinkname". + </para></listitem> + </varlistentry> + + <varlistentry> <term>rd <directory name></term> <listitem><para>See the rmdir command. </para></listitem> </varlistentry> diff --git a/source3/client/client.c b/source3/client/client.c index d7c554efc0..2edeb1ae2b 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -2733,6 +2733,54 @@ static int cmd_link(void) } /**************************************************************************** + UNIX readlink. +****************************************************************************/ + +static int cmd_readlink(void) +{ + TALLOC_CTX *ctx = talloc_tos(); + char *name= NULL; + char *buf = NULL; + char *targetname = NULL; + char linkname[PATH_MAX+1]; + struct cli_state *targetcli; + + if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) { + d_printf("readlink <name>\n"); + return 1; + } + name = talloc_asprintf(ctx, + "%s%s", + client_get_cur_dir(), + buf); + if (!name) { + return 1; + } + + if (!cli_resolve_path(ctx, "", auth_info, cli, name, &targetcli, &targetname)) { + d_printf("readlink %s: %s\n", name, cli_errstr(cli)); + return 1; + } + + if (!SERVER_HAS_UNIX_CIFS(targetcli)) { + d_printf("Server doesn't support UNIX CIFS calls.\n"); + return 1; + } + + if (!NT_STATUS_IS_OK(cli_posix_readlink(targetcli, name, + linkname, PATH_MAX+1))) { + d_printf("%s readlink on file %s\n", + cli_errstr(targetcli), name); + return 1; + } + + d_printf("%s -> %s\n", name, linkname); + + return 0; +} + + +/**************************************************************************** UNIX symlink. ****************************************************************************/ @@ -3953,6 +4001,7 @@ static struct { {"q",cmd_quit,"logoff the server",{COMPL_NONE,COMPL_NONE}}, {"queue",cmd_queue,"show the print queue",{COMPL_NONE,COMPL_NONE}}, {"quit",cmd_quit,"logoff the server",{COMPL_NONE,COMPL_NONE}}, + {"readlink",cmd_readlink,"filename Do a UNIX extensions readlink call on a symlink",{COMPL_REMOTE,COMPL_REMOTE}}, {"rd",cmd_rmdir,"<directory> remove a directory",{COMPL_NONE,COMPL_NONE}}, {"recurse",cmd_recurse,"toggle directory recursion for mget and mput",{COMPL_NONE,COMPL_NONE}}, {"reget",cmd_reget,"<remote name> [local name] get a file restarting at end of local file",{COMPL_REMOTE,COMPL_LOCAL}}, |