summaryrefslogtreecommitdiff
path: root/examples/libsmbclient/smbwrapper/smbsh.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-02-03 15:06:48 +1100
committerAndrew Bartlett <abartlet@samba.org>2012-02-09 01:58:24 +0100
commit4328f3ccf37d9a1baadbc55f658902e3b16ff125 (patch)
tree203f4238cd13e283b423ee97df6ce2714298fd7f /examples/libsmbclient/smbwrapper/smbsh.c
parentb93326b9689d0ad935eed35f7cf5201ad04ac1ff (diff)
downloadsamba-4328f3ccf37d9a1baadbc55f658902e3b16ff125.tar.gz
samba-4328f3ccf37d9a1baadbc55f658902e3b16ff125.tar.bz2
samba-4328f3ccf37d9a1baadbc55f658902e3b16ff125.zip
smbwrapper: Remove smbwrapper
There are now many better ways to access a remote SMB filesystem, which do not rely on LD_PRELOAD and the associated dangers. FUSE, gvfs and the CIFS VFS are all much better options which do not require knowing every possible libc entry point that can deal with a file descriptor. As an example of the maintainence that would be required to keep this going, recent changes to deal with thread races and close-on-exec have resulted in dup3(), but this isn't currently mapped. While this would not be hard to add, it illistrates why it is better to move to an interface designed for this task. Andrew Bartlett Autobuild-User: Andrew Bartlett <abartlet@samba.org> Autobuild-Date: Thu Feb 9 01:58:24 CET 2012 on sn-devel-104
Diffstat (limited to 'examples/libsmbclient/smbwrapper/smbsh.c')
-rw-r--r--examples/libsmbclient/smbwrapper/smbsh.c162
1 files changed, 0 insertions, 162 deletions
diff --git a/examples/libsmbclient/smbwrapper/smbsh.c b/examples/libsmbclient/smbwrapper/smbsh.c
deleted file mode 100644
index f2b5bf49fb..0000000000
--- a/examples/libsmbclient/smbwrapper/smbsh.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- Unix SMB/Netbios implementation.
- Version 2.0
- SMB wrapper functions - frontend
- Copyright (C) Andrew Tridgell 1998
- Copyright (C) Derrell Lipman 2003-2005
-
- 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 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <limits.h>
-#include <string.h>
-#include <libsmbclient.h>
-#include "bsd-strlfunc.h"
-
-#ifndef FALSE
-# define FALSE (0)
-# define TRUE (! FALSE)
-#endif
-
-static void smbsh_usage(void)
-{
- printf("smbsh [options] [command [args] ...]\n\n");
- printf(" -p prepend library name\n");
- printf(" -a append library name\n");
- printf(" -n");
- printf(" -W workgroup\n");
- printf(" -U username\n");
- printf(" -P prefix\n");
- printf(" -R resolve order\n");
- printf(" -d debug level\n");
- printf(" -l logfile\n");
- printf(" -L libdir\n");
- exit(0);
-}
-
-int main(int argc, char *argv[])
-{
- char *p, *u;
- char *libd = ".";
- char line[PATH_MAX], pre[PATH_MAX], post[PATH_MAX];
- int opt;
- int no_ask = 0;
- struct stat statbuf;
- extern char *optarg;
- extern int optind;
-
- *pre = *post = '\0';
-
- while ((opt = getopt(argc, argv, "p:a:d:nL:W:U:h")) != -1) {
- switch (opt) {
- case 'p': /* prepend library before smbwrapper.so */
- if (*pre != '\0')
- smbw_strlcat(pre, " ", sizeof(pre));
- smbw_strlcat(pre, optarg, sizeof(pre));
- break;
-
- case 'a': /* append library after smbwrapper.so */
- smbw_strlcat(post, " ", sizeof(post));
- smbw_strlcat(post, optarg, sizeof(post));
- break;
-
- case 'd':
- setenv("DEBUG", optarg, TRUE);
- break;
-
- case 'n': /* don't ask for username/password */
- no_ask++;
- break;
-
- case 'L':
- libd = optarg;
- break;
-
- case 'W':
- setenv("WORKGROUP", optarg, TRUE);
- break;
-
- case 'U':
- p = strchr(optarg,'%');
- if (p) {
- *p=0;
- setenv("PASSWORD", p+1, TRUE);
- }
- setenv("USER", optarg, TRUE);
- break;
-
- case 'h':
- default:
- smbsh_usage();
- }
- }
-
-
- if (! no_ask) {
- if (!getenv("USER")) {
- printf("Username: ");
- u = fgets(line, sizeof(line)-1, stdin);
- setenv("USER", u, TRUE);
- }
-
- if (!getenv("PASSWORD")) {
- p = getpass("Password: ");
- setenv("PASSWORD", p, TRUE);
- }
- }
-
- smbw_strlcpy(line, pre, PATH_MAX - strlen(line));
- smbw_strlcat(line, " ", sizeof(line));
- smbw_strlcat(line, libd, sizeof(line));
- smbw_strlcat(line, "/smbwrapper.so", sizeof(line));
- smbw_strlcat(line, post, sizeof(line));
- setenv("LD_PRELOAD", line, TRUE);
- setenv("LD_BIND_NOW", "true", TRUE);
-
- snprintf(line,sizeof(line)-1,"%s/smbwrapper.32.so", libd);
-
- if (stat(line, &statbuf) == 0 && S_ISREG(statbuf.st_mode)) {
- snprintf(line, sizeof(line)-1,
- "%s/smbwrapper.32.so:DEFAULT", libd);
- setenv("_RLD_LIST", line, TRUE);
- snprintf(line, sizeof(line)-1,
- "%s/smbwrapper.so:DEFAULT", libd);
- setenv("_RLDN32_LIST", line, TRUE);
- } else {
- snprintf(line,sizeof(line)-1,"%s/smbwrapper.so:DEFAULT", libd);
- setenv("_RLD_LIST", line, TRUE);
- }
-
- if (optind < argc) {
- execvp(argv[optind], &argv[optind]);
- } else {
- char *shellpath = getenv("SHELL");
-
- setenv("PS1", "smbsh$ ", TRUE);
-
- if(shellpath) {
- execl(shellpath,"smbsh", NULL);
- } else {
- setenv("SHELL", "/bin/sh", TRUE);
- execl("/bin/sh", "smbsh", NULL);
- }
- }
- printf("launch failed!\n");
- return 1;
-}