summaryrefslogtreecommitdiff
path: root/source4/lib/cmdline
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-12-29 23:14:33 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:49:00 -0500
commit46aa296cc94933082dbb4b9b2b1ed210a600ad2d (patch)
tree4ff030226a04636e81e4e08009f817803e78f4a5 /source4/lib/cmdline
parente7303fc26737486b81978e3caa77dc202fac45fa (diff)
downloadsamba-46aa296cc94933082dbb4b9b2b1ed210a600ad2d.tar.gz
samba-46aa296cc94933082dbb4b9b2b1ed210a600ad2d.tar.bz2
samba-46aa296cc94933082dbb4b9b2b1ed210a600ad2d.zip
r12592: Remove some useless dependencies
(This used to be commit ca8db1a0cd77682ac2c6dc4718f5d753a4fcc4db)
Diffstat (limited to 'source4/lib/cmdline')
-rw-r--r--source4/lib/cmdline/config.m496
-rw-r--r--source4/lib/cmdline/config.mk14
-rw-r--r--source4/lib/cmdline/getsmbpass.c158
-rw-r--r--source4/lib/cmdline/popt_common.c88
-rw-r--r--source4/lib/cmdline/popt_credentials.c115
-rw-r--r--source4/lib/cmdline/readline.c119
6 files changed, 124 insertions, 466 deletions
diff --git a/source4/lib/cmdline/config.m4 b/source4/lib/cmdline/config.m4
deleted file mode 100644
index dd956642cd..0000000000
--- a/source4/lib/cmdline/config.m4
+++ /dev/null
@@ -1,96 +0,0 @@
-#################################################
-
-###############################################
-# Readline included by default unless explicitly asked not to
-test "${with_readline+set}" != "set" && with_readline=yes
-
-# test for where we get readline() from
-AC_MSG_CHECKING(whether to use readline)
-AC_ARG_WITH(readline,
-[ --with-readline[=DIR] Look for readline include/libs in DIR (default=auto) ],
-[ case "$with_readline" in
- yes)
- AC_MSG_RESULT(yes)
-
- AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
- AC_CHECK_HEADERS(readline/history.h)
-
- AC_CHECK_HEADERS(readline.h readline/readline.h,[
- for termlib in ncurses curses termcap terminfo termlib tinfo; do
- AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
- done
- AC_CHECK_LIB(readline, rl_callback_handler_install,
- [TERMLIBS="-lreadline $TERMLIBS"
- AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline])
- break], [TERMLIBS=], $TERMLIBS)])
- ;;
- no)
- AC_MSG_RESULT(no)
- ;;
- *)
- AC_MSG_RESULT(yes)
-
- # Needed for AC_CHECK_HEADERS and AC_CHECK_LIB to look at
- # alternate readline path
- _ldflags=${LDFLAGS}
- _cppflags=${CPPFLAGS}
-
- # Add additional search path
- LDFLAGS="-L$with_readline/lib $LDFLAGS"
- CPPFLAGS="-I$with_readline/include $CPPFLAGS"
-
- AC_CHECK_HEADERS(readline.h history.h readline/readline.h)
- AC_CHECK_HEADERS(readline/history.h)
-
- AC_CHECK_HEADERS(readline.h readline/readline.h,[
- for termlib in ncurses curses termcap terminfo termlib; do
- AC_CHECK_LIB(${termlib}, tgetent, [TERMLIBS="-l${termlib}"; break])
- done
- AC_CHECK_LIB(readline, rl_callback_handler_install,
- [TERMLDFLAGS="-L$with_readline/lib"
- TERMCPPFLAGS="-I$with_readline/include"
- LDFLAGS="-L$with_readline/lib $LDFLAGS"
- CPPFLAGS="-I$with_readline/include $CPPFLAGS"
- TERMLIBS="-lreadline $TERMLIBS"
- AC_DEFINE(HAVE_LIBREADLINE,1,[Whether the system has readline])
- break], [TERMLIBS= CPPFLAGS=$_cppflags], $TERMLIBS)])
-
- ;;
- esac],
- AC_MSG_RESULT(no)
-)
-
-# The readline API changed slightly from readline3 to readline4, so
-# code will generate warnings on one of them unless we have a few
-# special cases.
-AC_CHECK_LIB(readline, rl_completion_matches,
- [AC_DEFINE(HAVE_NEW_LIBREADLINE, 1,
- [Do we have rl_completion_matches?])],
- [],
- [$TERMLIBS])
-
-TMP_LIBCMDLINE_OBJS="lib/cmdline/readline.o lib/cmdline/popt_common.o"
-TMP_LIBCMDLINE_LIBS="$TERMLIBS"
-
-SMB_EXT_LIB(READLINE, [${TMP_LIBCMDLINE_LIBS}])
-
-SMB_SUBSYSTEM(LIBCMDLINE,
- [${TMP_LIBCMDLINE_OBJS}],
- [LIBPOPT EXT_LIB_READLINE LIBCMDLINE_CREDENTIALS])
-
-AC_CACHE_CHECK([whether getpass should be replaced],samba_cv_REPLACE_GETPASS,[
-SAVE_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt -I${srcdir-.}/smbwrapper"
-AC_TRY_COMPILE([
-#define REPLACE_GETPASS 1
-#define NO_CONFIG_H 1
-#define main dont_declare_main
-#include "${srcdir-.}/lib/cmdline/getsmbpass.c"
-#undef main
-],[],samba_cv_REPLACE_GETPASS=yes,samba_cv_REPLACE_GETPASS=no)
-CPPFLAGS="$SAVE_CPPFLAGS"
-])
-if test x"$samba_cv_REPLACE_GETPASS" = x"yes"; then
- AC_DEFINE(REPLACE_GETPASS,1,[Whether getpass should be replaced])
-fi
-
diff --git a/source4/lib/cmdline/config.mk b/source4/lib/cmdline/config.mk
index 36f8ba7469..28e482d9b2 100644
--- a/source4/lib/cmdline/config.mk
+++ b/source4/lib/cmdline/config.mk
@@ -1,8 +1,10 @@
-##############################
-# Start SUBSYSTEM LIBCMDLINE_CREDENTIALS
[SUBSYSTEM::LIBCMDLINE_CREDENTIALS]
-OBJ_FILES = getsmbpass.o \
- credentials.o
+OBJ_FILES = credentials.o
REQUIRED_SUBSYSTEMS = CREDENTIALS
-# End SUBSYSTEM LIBCMDLINE_CREDENTIALS
-##############################
+
+[SUBSYSTEM::POPT_SAMBA]
+OBJ_FILES = popt_common.o
+
+[SUBSYSTEM::POPT_CREDENTIALS]
+OBJ_FILES = popt_credentials.o
+REQUIRED_SUBSYSTEMS = CREDENTIALS LIBCMDLINE_CREDENTIALS
diff --git a/source4/lib/cmdline/getsmbpass.c b/source4/lib/cmdline/getsmbpass.c
deleted file mode 100644
index 4ffcde8dfd..0000000000
--- a/source4/lib/cmdline/getsmbpass.c
+++ /dev/null
@@ -1,158 +0,0 @@
-/* Copyright (C) 1992-1998 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
-
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
-
-The GNU C Library 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
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
-
-/* Modified to use with samba by Jeremy Allison, 8th July 1995. */
-
-#include "includes.h"
-#include "system/terminal.h"
-#include "system/wait.h"
-
-#ifdef REPLACE_GETPASS
-
-#ifdef SYSV_TERMIO
-
-/* SYSTEM V TERMIO HANDLING */
-
-static struct termio t;
-
-#define ECHO_IS_ON(t) ((t).c_lflag & ECHO)
-#define TURN_ECHO_OFF(t) ((t).c_lflag &= ~ECHO)
-#define TURN_ECHO_ON(t) ((t).c_lflag |= ECHO)
-
-#ifndef TCSAFLUSH
-#define TCSAFLUSH 1
-#endif
-
-#ifndef TCSANOW
-#define TCSANOW 0
-#endif
-
-static int tcgetattr(int fd, struct termio *_t)
-{
- return ioctl(fd, TCGETA, _t);
-}
-
-static int tcsetattr(int fd, int flags, struct termio *_t)
-{
- if(flags & TCSAFLUSH)
- ioctl(fd, TCFLSH, TCIOFLUSH);
- return ioctl(fd, TCSETS, _t);
-}
-
-#elif !defined(TCSAFLUSH)
-
-/* BSD TERMIO HANDLING */
-
-static struct sgttyb t;
-
-#define ECHO_IS_ON(t) ((t).sg_flags & ECHO)
-#define TURN_ECHO_OFF(t) ((t).sg_flags &= ~ECHO)
-#define TURN_ECHO_ON(t) ((t).sg_flags |= ECHO)
-
-#define TCSAFLUSH 1
-#define TCSANOW 0
-
-static int tcgetattr(int fd, struct sgttyb *_t)
-{
- return ioctl(fd, TIOCGETP, (char *)_t);
-}
-
-static int tcsetattr(int fd, int flags, struct sgttyb *_t)
-{
- return ioctl(fd, TIOCSETP, (char *)_t);
-}
-
-#else /* POSIX TERMIO HANDLING */
-#define ECHO_IS_ON(t) ((t).c_lflag & ECHO)
-#define TURN_ECHO_OFF(t) ((t).c_lflag &= ~ECHO)
-#define TURN_ECHO_ON(t) ((t).c_lflag |= ECHO)
-
-static struct termios t;
-#endif /* SYSV_TERMIO */
-
-char *getsmbpass(const char *prompt)
-{
- FILE *in, *out;
- int echo_off;
- static char buf[256];
- static size_t bufsize = sizeof(buf);
- size_t nread;
-
- /* Catch problematic signals */
- CatchSignal(SIGINT, SIGNAL_CAST SIG_IGN);
-
- /* Try to write to and read from the terminal if we can.
- If we can't open the terminal, use stderr and stdin. */
-
- in = fopen ("/dev/tty", "w+");
- if (in == NULL)
- {
- in = stdin;
- out = stderr;
- }
- else
- out = in;
-
- setvbuf(in, NULL, _IONBF, 0);
-
- /* Turn echoing off if it is on now. */
-
- if (tcgetattr (fileno (in), &t) == 0)
- {
- if (ECHO_IS_ON(t))
- {
- TURN_ECHO_OFF(t);
- echo_off = tcsetattr (fileno (in), TCSAFLUSH, &t) == 0;
- TURN_ECHO_ON(t);
- }
- else
- echo_off = 0;
- }
- else
- echo_off = 0;
-
- /* Write the prompt. */
- fputs (prompt, out);
- fflush (out);
-
- /* Read the password. */
- buf[0] = 0;
- fgets(buf, bufsize, in);
- nread = strlen(buf);
- if (buf[nread - 1] == '\n')
- buf[nread - 1] = '\0';
-
- /* Restore echoing. */
- if (echo_off)
- (void) tcsetattr (fileno (in), TCSANOW, &t);
-
- if (in != stdin)
- /* We opened the terminal; now close it. */
- fclose (in);
-
- /* Catch problematic signals */
- CatchSignal(SIGINT, SIGNAL_CAST SIG_DFL);
-
- printf("\n");
- return buf;
-}
-
-#else
- void getsmbpasswd_dummy(void);
- void getsmbpasswd_dummy(void) {;}
-#endif
diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c
index b1f4563fb1..b8c5b5b9d3 100644
--- a/source4/lib/cmdline/popt_common.c
+++ b/source4/lib/cmdline/popt_common.c
@@ -37,7 +37,7 @@
* -i,--scope
*/
-enum {OPT_OPTION=1,OPT_LEAK_REPORT,OPT_LEAK_REPORT_FULL, OPT_DEBUG_STDERR, OPT_SIMPLE_BIND_DN};
+enum {OPT_OPTION=1,OPT_LEAK_REPORT,OPT_LEAK_REPORT_FULL,OPT_DEBUG_STDERR};
struct cli_credentials *cmdline_credentials = NULL;
@@ -173,89 +173,3 @@ struct poptOption popt_common_version[] = {
POPT_TABLEEND
};
-/* Handle command line options:
- * -U,--user
- * -A,--authentication-file
- * -k,--use-kerberos
- * -N,--no-pass
- * -S,--signing
- * -P --machine-pass
- */
-
-
-static BOOL dont_ask;
-
-/*
- disable asking for a password
-*/
-void popt_common_dont_ask(void)
-{
- dont_ask = True;
-}
-
-static void popt_common_credentials_callback(poptContext con,
- enum poptCallbackReason reason,
- const struct poptOption *opt,
- const char *arg, const void *data)
-{
- if (reason == POPT_CALLBACK_REASON_PRE) {
- cmdline_credentials = cli_credentials_init(talloc_autofree_context());
- return;
- }
-
- if (reason == POPT_CALLBACK_REASON_POST) {
- cli_credentials_guess(cmdline_credentials);
-
- if (!dont_ask) {
- cli_credentials_set_cmdline_callbacks(cmdline_credentials);
- }
- return;
- }
-
- switch(opt->val) {
- case 'U':
- {
- char *lp;
-
- cli_credentials_parse_string(cmdline_credentials, arg, CRED_SPECIFIED);
- /* This breaks the abstraction, including the const above */
- if ((lp=strchr_m(arg,'%'))) {
- lp[0]='\0';
- lp++;
- memset(lp,0,strlen(lp));
- }
- }
- break;
-
- case 'A':
- cli_credentials_parse_file(cmdline_credentials, arg, CRED_SPECIFIED);
- break;
-
- case 'S':
- lp_set_cmdline("client signing", arg);
- break;
-
- case 'P':
- /* Later, after this is all over, get the machine account details from the secrets.ldb */
- cli_credentials_set_machine_account_pending(cmdline_credentials);
-
- /* machine accounts only work with kerberos (fall though)*/
- break;
- case OPT_SIMPLE_BIND_DN:
- cli_credentials_set_bind_dn(cmdline_credentials, arg);
- break;
- }
-}
-
-
-
-struct poptOption popt_common_credentials[] = {
- { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE|POPT_CBFLAG_POST, popt_common_credentials_callback },
- { "user", 'U', POPT_ARG_STRING, NULL, 'U', "Set the network username", "[DOMAIN\\]USERNAME[%PASSWORD]" },
- { "no-pass", 'N', POPT_ARG_NONE, &dont_ask, True, "Don't ask for a password" },
- { "authentication-file", 'A', POPT_ARG_STRING, NULL, 'A', "Get the credentials from a file", "FILE" },
- { "signing", 'S', POPT_ARG_STRING, NULL, 'S', "Set the client signing state", "on|off|required" },
- { "machine-pass", 'P', POPT_ARG_NONE, NULL, 'P', "Use stored machine account password (implies -k)" },
- { "simple-bind-dn", 0, POPT_ARG_STRING, NULL, OPT_SIMPLE_BIND_DN, "DN to use for a simple bind" },
- POPT_TABLEEND
-};
diff --git a/source4/lib/cmdline/popt_credentials.c b/source4/lib/cmdline/popt_credentials.c
new file mode 100644
index 0000000000..a974d808e3
--- /dev/null
+++ b/source4/lib/cmdline/popt_credentials.c
@@ -0,0 +1,115 @@
+/*
+ Unix SMB/CIFS implementation.
+ Credentials popt routines
+
+ Copyright (C) Jelmer Vernooij 2002,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 2 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, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "version.h"
+#include "system/filesys.h"
+#include "system/passwd.h"
+#include "lib/cmdline/popt_common.h"
+
+/* Handle command line options:
+ * -U,--user
+ * -A,--authentication-file
+ * -k,--use-kerberos
+ * -N,--no-pass
+ * -S,--signing
+ * -P --machine-pass
+ */
+
+
+static BOOL dont_ask;
+
+enum opt { OPT_SIMPLE_BIND_DN };
+
+/*
+ disable asking for a password
+*/
+void popt_common_dont_ask(void)
+{
+ dont_ask = True;
+}
+
+static void popt_common_credentials_callback(poptContext con,
+ enum poptCallbackReason reason,
+ const struct poptOption *opt,
+ const char *arg, const void *data)
+{
+ if (reason == POPT_CALLBACK_REASON_PRE) {
+ cmdline_credentials = cli_credentials_init(talloc_autofree_context());
+ return;
+ }
+
+ if (reason == POPT_CALLBACK_REASON_POST) {
+ cli_credentials_guess(cmdline_credentials);
+
+ if (!dont_ask) {
+ cli_credentials_set_cmdline_callbacks(cmdline_credentials);
+ }
+ return;
+ }
+
+ switch(opt->val) {
+ case 'U':
+ {
+ char *lp;
+
+ cli_credentials_parse_string(cmdline_credentials, arg, CRED_SPECIFIED);
+ /* This breaks the abstraction, including the const above */
+ if ((lp=strchr_m(arg,'%'))) {
+ lp[0]='\0';
+ lp++;
+ memset(lp,0,strlen(lp));
+ }
+ }
+ break;
+
+ case 'A':
+ cli_credentials_parse_file(cmdline_credentials, arg, CRED_SPECIFIED);
+ break;
+
+ case 'S':
+ lp_set_cmdline("client signing", arg);
+ break;
+
+ case 'P':
+ /* Later, after this is all over, get the machine account details from the secrets.ldb */
+ cli_credentials_set_machine_account_pending(cmdline_credentials);
+
+ /* machine accounts only work with kerberos (fall though)*/
+ break;
+ case OPT_SIMPLE_BIND_DN:
+ cli_credentials_set_bind_dn(cmdline_credentials, arg);
+ break;
+ }
+}
+
+
+
+struct poptOption popt_common_credentials[] = {
+ { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE|POPT_CBFLAG_POST, popt_common_credentials_callback },
+ { "user", 'U', POPT_ARG_STRING, NULL, 'U', "Set the network username", "[DOMAIN\\]USERNAME[%PASSWORD]" },
+ { "no-pass", 'N', POPT_ARG_NONE, &dont_ask, True, "Don't ask for a password" },
+ { "authentication-file", 'A', POPT_ARG_STRING, NULL, 'A', "Get the credentials from a file", "FILE" },
+ { "signing", 'S', POPT_ARG_STRING, NULL, 'S', "Set the client signing state", "on|off|required" },
+ { "machine-pass", 'P', POPT_ARG_NONE, NULL, 'P', "Use stored machine account password (implies -k)" },
+ { "simple-bind-dn", 0, POPT_ARG_STRING, NULL, OPT_SIMPLE_BIND_DN, "DN to use for a simple bind" },
+ POPT_TABLEEND
+};
diff --git a/source4/lib/cmdline/readline.c b/source4/lib/cmdline/readline.c
deleted file mode 100644
index 52f45eb759..0000000000
--- a/source4/lib/cmdline/readline.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Samba readline wrapper implementation
- Copyright (C) Simo Sorce 2001
- Copyright (C) Andrew Tridgell 2001
-
- 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
- (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, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#include "includes.h"
-#include "pstring.h"
-
-#include <unistd.h>
-#include "system/readline.h"
-
-/****************************************************************************
- Display the prompt and wait for input. Call callback() regularly
-****************************************************************************/
-
-static char *smb_readline_replacement(const char *prompt, void (*callback)(void),
- char **(completion_fn)(const char *text, int start, int end))
-{
- fd_set fds;
- static pstring line;
- struct timeval timeout;
- int fd = STDIN_FILENO;
- char *ret;
-
- do_debug("%s", prompt);
-
- while (1) {
- timeout.tv_sec = 5;
- timeout.tv_usec = 0;
-
- FD_ZERO(&fds);
- FD_SET(fd,&fds);
-
- if (sys_select_intr(fd+1,&fds,NULL,NULL,&timeout) == 1) {
- ret = x_fgets(line, sizeof(line), x_stdin);
- return ret;
- }
- if (callback)
- callback();
- }
-}
-
-/****************************************************************************
- Display the prompt and wait for input. Call callback() regularly.
-****************************************************************************/
-
-char *smb_readline(const char *prompt, void (*callback)(void),
- char **(completion_fn)(const char *text, int start, int end))
-{
-#if HAVE_LIBREADLINE
- if (isatty(STDIN_FILENO)) {
- char *ret;
-
- /* Aargh! Readline does bizzare things with the terminal width
- that mucks up expect(1). Set CLI_NO_READLINE in the environment
- to force readline not to be used. */
-
- if (getenv("CLI_NO_READLINE"))
- return smb_readline_replacement(prompt, callback, completion_fn);
-
- if (completion_fn) {
- /* The callback prototype has changed slightly between
- different versions of Readline, so the same function
- works in all of them to date, but we get compiler
- warnings in some. */
- rl_attempted_completion_function = RL_COMPLETION_CAST completion_fn;
- }
-
- if (callback)
- rl_event_hook = (Function *)callback;
- ret = readline(prompt);
- if (ret && *ret)
- add_history(ret);
- return ret;
- } else
-#endif
- return smb_readline_replacement(prompt, callback, completion_fn);
-}
-
-/****************************************************************************
- * return line buffer text
- ****************************************************************************/
-const char *smb_readline_get_line_buffer(void)
-{
-#if defined(HAVE_LIBREADLINE)
- return rl_line_buffer;
-#else
- return NULL;
-#endif
-}
-
-/****************************************************************************
- * set completion append character
- ***************************************************************************/
-void smb_readline_ca_char(char c)
-{
-#if defined(HAVE_LIBREADLINE)
- rl_completion_append_character = c;
-#endif
-}
-
-
-