From 46aa296cc94933082dbb4b9b2b1ed210a600ad2d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 29 Dec 2005 23:14:33 +0000 Subject: r12592: Remove some useless dependencies (This used to be commit ca8db1a0cd77682ac2c6dc4718f5d753a4fcc4db) --- source4/lib/replace/getpass.c | 158 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 source4/lib/replace/getpass.c (limited to 'source4/lib/replace/getpass.c') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c new file mode 100644 index 0000000000..4ffcde8dfd --- /dev/null +++ b/source4/lib/replace/getpass.c @@ -0,0 +1,158 @@ +/* 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 -- cgit From 38fdde5d9bf15b10caa60ee216d278ba8d870c2e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 4 Sep 2006 12:21:42 +0000 Subject: r18031: Merge my replace fixes: * libreplace can now build stand-alone * add stub testsuite for libreplace * make talloc/tdb/ldb use libreplace (This used to be commit fe7ca4b1454e01a33ed0d53791ebffdd349298b4) --- source4/lib/replace/getpass.c | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) (limited to 'source4/lib/replace/getpass.c') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index 4ffcde8dfd..1aac7c61ab 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -18,9 +18,38 @@ 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" +#include "replace.h" +#include + +#if defined(HAVE_TERMIOS_H) +/* POSIX terminal handling. */ +#include +#elif defined(HAVE_TERMIO_H) +/* Older SYSV terminal handling - don't use if we can avoid it. */ +#include +#elif defined(HAVE_SYS_TERMIO_H) +/* Older SYSV terminal handling - don't use if we can avoid it. */ +#include +#endif + +#ifdef HAVE_SYS_WAIT_H +#include +#endif + +/* + * Define additional missing types + */ +#ifndef HAVE_SIG_ATOMIC_T_TYPE +typedef int sig_atomic_t; +#endif + +#ifndef SIGCLD +#define SIGCLD SIGCHLD +#endif + +#ifndef SIGNAL_CAST +#define SIGNAL_CAST (RETSIGTYPE (*)(int)) +#endif #ifdef REPLACE_GETPASS -- cgit From cdd352bfcb5aab71558961ee46068f7b89c1ba80 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 6 Sep 2006 05:27:01 +0000 Subject: r18132: getpass can't depend on fns in lib/util/ (This used to be commit b346ab2f0573177e0a4654fd7c77a071225fc785) --- source4/lib/replace/getpass.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace/getpass.c') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index 1aac7c61ab..05fb7976b9 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -114,6 +114,32 @@ static int tcsetattr(int fd, int flags, struct sgttyb *_t) static struct termios t; #endif /* SYSV_TERMIO */ +static void catch_signal(int signum,void (*handler)(int )) +{ +#ifdef HAVE_SIGACTION + struct sigaction act; + struct sigaction oldact; + + memset(&act, 0, sizeof(act)); + + act.sa_handler = handler; +#ifdef SA_RESTART + /* + * We *want* SIGALRM to interrupt a system call. + */ + if(signum != SIGALRM) + act.sa_flags = SA_RESTART; +#endif + sigemptyset(&act.sa_mask); + sigaddset(&act.sa_mask,signum); + sigaction(signum,&act,&oldact); + return oldact.sa_handler; +#else /* !HAVE_SIGACTION */ + /* FIXME: need to handle sigvec and systems with broken signal() */ + return signal(signum, handler); +#endif +} + char *getsmbpass(const char *prompt) { FILE *in, *out; @@ -123,7 +149,7 @@ char *getsmbpass(const char *prompt) size_t nread; /* Catch problematic signals */ - CatchSignal(SIGINT, SIGNAL_CAST SIG_IGN); + catch_signal(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. */ @@ -175,7 +201,7 @@ char *getsmbpass(const char *prompt) fclose (in); /* Catch problematic signals */ - CatchSignal(SIGINT, SIGNAL_CAST SIG_DFL); + catch_signal(SIGINT, SIGNAL_CAST SIG_DFL); printf("\n"); return buf; -- cgit From 3ca73facc59ed8a97abbc28c1b4bedde87e109a6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 6 Sep 2006 11:31:59 +0000 Subject: r18160: - pread and pwrite replacements need to be non-static - replacing rename() is pointless - all platforms have it (and the #define of rename breaks some code) - use system/locale.h in snprintf.c - fix passwd.h for initgroups - stdlib is in replace.h, not needed elsewhere - fix the initgroups replacement - fix mapping of dl functions to rep_* (This used to be commit 57cd0ca176387d6a3acabf9fedeef4f2a3a3dad7) --- source4/lib/replace/getpass.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/replace/getpass.c') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index 05fb7976b9..2ccbf7b733 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -19,7 +19,6 @@ Cambridge, MA 02139, USA. */ /* Modified to use with samba by Jeremy Allison, 8th July 1995. */ #include "replace.h" -#include #if defined(HAVE_TERMIOS_H) /* POSIX terminal handling. */ -- cgit From 4b71c210d5aa01fc5934ea1777a1c8a7ed1e1f37 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 03:04:16 +0000 Subject: r23796: main COPYING file for samba4, plus some formatting varients (This used to be commit 76c6bfdeb51b5673bbabe0ca3d8bff3b74a327ee) --- source4/lib/replace/getpass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace/getpass.c') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index 2ccbf7b733..2cbb30e2da 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -3,7 +3,7 @@ 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 +published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, -- cgit From b8875bee5f0c5385ba02646c7a8b2380fdfabb7a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 04:04:46 +0000 Subject: r23800: LGPL is now called GNU Lesser General Public License not GNU Library General Public License (This used to be commit 01e3fe7533b5670236c026ec3c6cc1e25655fbc3) --- source4/lib/replace/getpass.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace/getpass.c') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index 2cbb30e2da..9e975ee7ef 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -2,7 +2,7 @@ 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 +modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. @@ -11,7 +11,7 @@ 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 +You should have received a copy of the GNU Lesser 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. */ -- cgit From cd1217ff5ff18e53c6c9fa3d4f4fd56193fe2a17 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 05:23:25 +0000 Subject: r23801: The FSF has moved around a lot. This fixes their Mass Ave address. (This used to be commit 5c9b19271e0e3ad897499707003ce4703ffa4870) --- source4/lib/replace/getpass.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/lib/replace/getpass.c') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index 9e975ee7ef..f6a72ad86a 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -13,8 +13,7 @@ Library General Public License for more details. You should have received a copy of the GNU Lesser 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. */ +not, see . */ /* Modified to use with samba by Jeremy Allison, 8th July 1995. */ -- cgit From 090015a6fb40cf3dd925bc7db9015f91567c475e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 17 Oct 2007 14:00:09 +0200 Subject: r25678: reformat getpass() replacement code metze (cherry picked from commit 3e8f43e3cf97f10be4717978643ef3edca8650a5) (This used to be commit 78da4477a7ef920ff77b41abb841465511b8db31) --- source4/lib/replace/getpass.c | 120 ++++++++++++++++++++---------------------- 1 file changed, 58 insertions(+), 62 deletions(-) (limited to 'source4/lib/replace/getpass.c') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index f6a72ad86a..eb69e68f19 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -140,69 +140,65 @@ static void catch_signal(int signum,void (*handler)(int )) 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 */ - catch_signal(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); + FILE *in, *out; + int echo_off; + static char buf[256]; + static size_t bufsize = sizeof(buf); + size_t nread; + + /* Catch problematic signals */ + catch_signal(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; } - 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 */ - catch_signal(SIGINT, SIGNAL_CAST SIG_DFL); - - printf("\n"); - return buf; + + 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) + tcsetattr (fileno (in), TCSANOW, &t); + + if (in != stdin) /* We opened the terminal; now close it. */ + fclose(in); + + /* Catch problematic signals */ + catch_signal(SIGINT, SIGNAL_CAST SIG_DFL); + + printf("\n"); + return buf; } #else -- cgit From 2627603506452debf018e2ed8ae0b7912d64e58e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 17 Oct 2007 14:00:23 +0200 Subject: r25679: reapply: Allow ^C to interrupt smbpasswd if using our getpass. from Jeremy metze (cherry picked from commit d4ae42b1b2982dd786d6da16d7fa964d25fd3356) (This used to be commit a11d21790fc2ee33998e042195ccbad73631bad8) --- source4/lib/replace/getpass.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'source4/lib/replace/getpass.c') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index eb69e68f19..1cabf0bd87 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -138,6 +138,21 @@ static void catch_signal(int signum,void (*handler)(int )) #endif } +static sig_atomic_t gotintr; +static int in_fd = -1; + +/*************************************************************** + Signal function to tell us were ^C'ed. +****************************************************************/ + +static void gotintr_sig(void) +{ + gotintr = 1; + if (in_fd != -1) + close(in_fd); /* Safe way to force a return. */ + in_fd = -1; +} + char *getsmbpass(const char *prompt) { FILE *in, *out; @@ -147,7 +162,7 @@ char *getsmbpass(const char *prompt) size_t nread; /* Catch problematic signals */ - catch_signal(SIGINT, SIGNAL_CAST SIG_IGN); + catch_signal(SIGINT, SIGNAL_CAST gotintr_sig); /* Try to write to and read from the terminal if we can. If we can't open the terminal, use stderr and stdin. */ @@ -182,14 +197,21 @@ char *getsmbpass(const char *prompt) /* Read the password. */ buf[0] = 0; - fgets(buf, bufsize, in); + if (!gotintr) { + in_fd = fileno(in); + fgets(buf, bufsize, in); + } nread = strlen(buf); if (buf[nread - 1] == '\n') buf[nread - 1] = '\0'; /* Restore echoing. */ - if (echo_off) - tcsetattr (fileno (in), TCSANOW, &t); + if (echo_off) { + if (gotintr && in_fd == -1) + in = fopen ("/dev/tty", "w+"); + if (in != NULL) + tcsetattr (fileno (in), TCSANOW, &t); + } if (in != stdin) /* We opened the terminal; now close it. */ fclose(in); @@ -198,6 +220,12 @@ char *getsmbpass(const char *prompt) catch_signal(SIGINT, SIGNAL_CAST SIG_DFL); printf("\n"); + + if (gotintr) { + printf("Interupted by signal.\n"); + fflush(stdout); + exit(1); + } return buf; } -- cgit From 50a749404bb1d86f0881fab06414469fda307c26 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 17 Oct 2007 14:00:42 +0200 Subject: r25680: Volker's fix for bug #668. Change the \n after the password prompt to go to tty instead of stdout. (cherry picked from commit 0cd1ed0424ce87f60070d43caffda41be6706d59) (This used to be commit 249d69fd85b67657a4523ffc9244a8b4ab01270a) --- source4/lib/replace/getpass.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace/getpass.c') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index 1cabf0bd87..96f508ead2 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -213,14 +213,15 @@ char *getsmbpass(const char *prompt) tcsetattr (fileno (in), TCSANOW, &t); } + fprintf(out, "\n"); + fflush(out); + if (in != stdin) /* We opened the terminal; now close it. */ fclose(in); /* Catch problematic signals */ catch_signal(SIGINT, SIGNAL_CAST SIG_DFL); - printf("\n"); - if (gotintr) { printf("Interupted by signal.\n"); fflush(stdout); -- cgit From 066f56bfeffcbd4808606d4a81c0f0cefa92e07e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 17 Oct 2007 14:00:57 +0200 Subject: r25681: r16245: Cope with string being zero len. Klocwork bug #410. Jeremy. (cherry picked from commit 46c12de07fe6f44bcf58ca9de276e7932384843d) (This used to be commit 7099dde3fd8962e752451ebe2d5d79de4d7caee9) --- source4/lib/replace/getpass.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source4/lib/replace/getpass.c') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index 96f508ead2..c67ff2bda7 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -202,8 +202,10 @@ char *getsmbpass(const char *prompt) fgets(buf, bufsize, in); } nread = strlen(buf); - if (buf[nread - 1] == '\n') - buf[nread - 1] = '\0'; + if (nread) { + if (buf[nread - 1] == '\n') + buf[nread - 1] = '\0'; + } /* Restore echoing. */ if (echo_off) { -- cgit From 190039a378ee208a026f868d083d7c00918d1b5f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 17 Oct 2007 14:01:15 +0200 Subject: r25682: r16320: Ensure variable is not null before calling fclose. Klocwork #412. Jeremy. (cherry picked from commit 33ee0cfb190a883229d0824d7194898fd8966ceb) (This used to be commit 3910d069413834744b17175bb29775a69002712e) --- source4/lib/replace/getpass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace/getpass.c') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index c67ff2bda7..dace5fbb8a 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -218,7 +218,7 @@ char *getsmbpass(const char *prompt) fprintf(out, "\n"); fflush(out); - if (in != stdin) /* We opened the terminal; now close it. */ + if (in && in != stdin) /* We opened the terminal; now close it. */ fclose(in); /* Catch problematic signals */ -- cgit From 2367364094824e03ce890e961bdb70d42c57471f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 17 Oct 2007 14:01:34 +0200 Subject: r25683: fix the compilation of getpass.c and it's configure test metze (cherry picked from commit f4c0961a16a84dcdfe6e2faafb75c76983e6d466) (This used to be commit 5d747fcad0b0ac66584da500148e7647122e0544) --- source4/lib/replace/getpass.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'source4/lib/replace/getpass.c') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index dace5fbb8a..4b21849089 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -49,8 +49,6 @@ typedef int sig_atomic_t; #define SIGNAL_CAST (RETSIGTYPE (*)(int)) #endif -#ifdef REPLACE_GETPASS - #ifdef SYSV_TERMIO /* SYSTEM V TERMIO HANDLING */ @@ -131,10 +129,9 @@ static void catch_signal(int signum,void (*handler)(int )) sigemptyset(&act.sa_mask); sigaddset(&act.sa_mask,signum); sigaction(signum,&act,&oldact); - return oldact.sa_handler; #else /* !HAVE_SIGACTION */ /* FIXME: need to handle sigvec and systems with broken signal() */ - return signal(signum, handler); + signal(signum, handler); #endif } @@ -231,8 +228,3 @@ char *getsmbpass(const char *prompt) } return buf; } - -#else - void getsmbpasswd_dummy(void); - void getsmbpasswd_dummy(void) {;} -#endif -- cgit From de0343b77bcbe0ad19f02c0894f703ade4d7fff2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 17 Oct 2007 14:01:49 +0200 Subject: r25684: use "system/*.h" to get the system includes metze (cherry picked from commit d20c2fa274297e9577ed28b8ed04806a425bdc57) (This used to be commit ee8557783534ac5b075a8a4655a12b33b854c050) --- source4/lib/replace/getpass.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'source4/lib/replace/getpass.c') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index 4b21849089..f4819e9df5 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -18,21 +18,9 @@ not, see . */ /* Modified to use with samba by Jeremy Allison, 8th July 1995. */ #include "replace.h" - -#if defined(HAVE_TERMIOS_H) -/* POSIX terminal handling. */ -#include -#elif defined(HAVE_TERMIO_H) -/* Older SYSV terminal handling - don't use if we can avoid it. */ -#include -#elif defined(HAVE_SYS_TERMIO_H) -/* Older SYSV terminal handling - don't use if we can avoid it. */ -#include -#endif - -#ifdef HAVE_SYS_WAIT_H -#include -#endif +#include "system/filesys.h" +#include "system/wait.h" +#include "system/terminal.h" /* * Define additional missing types -- cgit From c68e3d8d652109edd95999755b31fd123bbffc90 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 17 Oct 2007 14:02:06 +0200 Subject: r25685: rename getsmbpass -> rep_getpass and provide the function prototype metze (cherry picked from commit 96820f8d8f6522fc264efda0f069e2f6a420ac2e) (This used to be commit cd5069a8ca17a3a14814c0fbf55f113690291165) --- source4/lib/replace/getpass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/replace/getpass.c') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index f4819e9df5..1d13461573 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -138,7 +138,7 @@ static void gotintr_sig(void) in_fd = -1; } -char *getsmbpass(const char *prompt) +char *rep_getpass(const char *prompt) { FILE *in, *out; int echo_off; -- cgit From 88f0c3bfa7773999d2a6dfd1123c95f019e87d84 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 9 Nov 2007 08:42:55 +0100 Subject: r25912: Two patches Hi! Can you check and push them? Thanks, Volker From b488af5905e2dee12a1a72a3b40801ae5c26f24f Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 27 Oct 2007 14:20:09 +0200 Subject: [PATCH] Fix some warnings and errors merge from v3-2-test commit e17d3e10e860c96b6d5208e5fe51e43b8e58c174 (This used to be commit 4087731e1b4e97017c0f5659e6659e8181d8e038) --- source4/lib/replace/getpass.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/replace/getpass.c') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index 1d13461573..d91d029f6a 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -21,6 +21,7 @@ not, see . */ #include "system/filesys.h" #include "system/wait.h" #include "system/terminal.h" +#include "system/passwd.h" /* * Define additional missing types -- cgit From 7fb3963032ce8f6b7f5c652dd69d3315cae897ea Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 23 Feb 2008 10:42:43 +0100 Subject: Check the return value of fgets (cherry picked from commit b8aaa9a69fd6217ce0387ef8e84f316706186d70) (This used to be commit 8f58d39c0c621e9da85308d721a146352cc4939e) --- source4/lib/replace/getpass.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/lib/replace/getpass.c') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index d91d029f6a..57e28eb981 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -185,7 +185,10 @@ char *rep_getpass(const char *prompt) buf[0] = 0; if (!gotintr) { in_fd = fileno(in); - fgets(buf, bufsize, in); + if (fgets(buf, bufsize, in) == NULL) { + buf[0] = 0; + return buf; + } } nread = strlen(buf); if (nread) { -- cgit From 6f6d38d24a69aec614e443c6a5cd0d6ed6b1b70e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 15 Mar 2008 22:27:05 +0100 Subject: Fix Coverity ID 554 (cherry picked from commit 471b1b0c58bc2def5d2fe9d98401def34724d447) (This used to be commit effda48a2670325fed56e158539417c6f95381b8) --- source4/lib/replace/getpass.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/replace/getpass.c') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index 57e28eb981..73333b9021 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -187,6 +187,9 @@ char *rep_getpass(const char *prompt) in_fd = fileno(in); if (fgets(buf, bufsize, in) == NULL) { buf[0] = 0; + if (in && in != stdin) { + fclose(in); + } return buf; } } -- cgit From b2c4838543fc2e42771a34cc9aa05f03793b88fc Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 9 May 2008 14:51:45 -0700 Subject: Fix replacement getpass. If we ^C at the prompt echo was left off. Jeremy. (cherry picked from commit e54c71954ae484fe4a4e195db33440490e78e256) (This used to be commit d61a86b8cdb4dd474611baadc61a0c37db0f8e62) --- source4/lib/replace/getpass.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'source4/lib/replace/getpass.c') diff --git a/source4/lib/replace/getpass.c b/source4/lib/replace/getpass.c index 73333b9021..0be618fc91 100644 --- a/source4/lib/replace/getpass.c +++ b/source4/lib/replace/getpass.c @@ -187,10 +187,6 @@ char *rep_getpass(const char *prompt) in_fd = fileno(in); if (fgets(buf, bufsize, in) == NULL) { buf[0] = 0; - if (in && in != stdin) { - fclose(in); - } - return buf; } } nread = strlen(buf); @@ -201,8 +197,9 @@ char *rep_getpass(const char *prompt) /* Restore echoing. */ if (echo_off) { - if (gotintr && in_fd == -1) + if (gotintr && in_fd == -1) { in = fopen ("/dev/tty", "w+"); + } if (in != NULL) tcsetattr (fileno (in), TCSANOW, &t); } -- cgit