From 7f21b7e693d39adae9c2cee8350ee6ffeff77c21 Mon Sep 17 00:00:00 2001 From: Matt Chapman Date: Sun, 6 Oct 2002 13:30:30 +0000 Subject: [PATCH] Remove -P (askpass program) git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@212 423420c4-83ab-492f-b58f-81f9feb106b5 --- doc/rdesktop.1 | 13 ++--- rdesktop.c | 14 +---- readpass.c | 141 ------------------------------------------------- 3 files changed, 5 insertions(+), 163 deletions(-) delete mode 100644 readpass.c diff --git a/doc/rdesktop.1 b/doc/rdesktop.1 index 180ab59..ef6af2b 100644 --- a/doc/rdesktop.1 +++ b/doc/rdesktop.1 @@ -34,15 +34,10 @@ The current working directory for the user. Often used in combination with -s to setup a fixed environment for the user after logon. .TP .BR "-p " -The password to authenticate with, used in combination with -u for -autologon. Use -p - to make rdesktop request a password at startup. -WARNING: the -p option will be visible to all users when -they use tools like ps. The -P option is safer. -.TP -.BR "-P " -The program to fetch the password from. The program will be executed, -and the output will be used as the password. This is a safe way to -transfer the password to rdesktop. +The password to authenticate with. Use -p - to make rdesktop request a +password at startup (from standard input). +WARNING: if you specify a password on the command line it may be visible +to other users when they use tools like ps. .TP .BR "-n " Client name. The default is the hostname. diff --git a/rdesktop.c b/rdesktop.c index 13aff2c..6b04d3a 100644 --- a/rdesktop.c +++ b/rdesktop.c @@ -60,7 +60,6 @@ usage(char *program) fprintf(stderr, " -s: shell\n"); fprintf(stderr, " -c: working directory\n"); fprintf(stderr, " -p: password (- to prompt)\n"); - fprintf(stderr, " -P: askpass-program (autologon)\n"); fprintf(stderr, " -n: client hostname\n"); fprintf(stderr, " -k: keyboard layout on terminal server (us,sv,gr etc.)\n"); fprintf(stderr, " -g: desktop geometry (WxH)\n"); @@ -117,7 +116,6 @@ main(int argc, char *argv[]) char fullhostname[64]; char domain[16]; char password[16]; - char *askpass_result; char shell[32]; char directory[32]; BOOL prompt_password; @@ -131,7 +129,7 @@ main(int argc, char *argv[]) domain[0] = password[0] = shell[0] = directory[0] = 0; strcpy(keymapname, "us"); - while ((c = getopt(argc, argv, "u:d:s:c:p:P:n:k:g:t:fbemlKw:h?")) != -1) + while ((c = getopt(argc, argv, "u:d:s:c:p:n:k:g:t:fbemlKw:h?")) != -1) { switch (c) { @@ -167,16 +165,6 @@ main(int argc, char *argv[]) *(p++) = 'X'; break; - case 'P': - askpass_result = askpass(optarg, "Enter password"); - if (askpass_result == NULL) - exit(1); - - STRNCPY(password, askpass_result, sizeof(password)); - free(askpass_result); - flags |= RDP_LOGON_AUTO; - break; - case 'n': STRNCPY(hostname, optarg, sizeof(hostname)); break; diff --git a/readpass.c b/readpass.c deleted file mode 100644 index 5c8e0a0..0000000 --- a/readpass.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - rdesktop: A Remote Desktop Protocol client. - User interface services - X keyboard mapping - Copyright (C) Matthew Chapman 1999-2002 - - 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 -#include -#include -#include -#include "rdesktop.h" -#include -#include -#include -#include -#include - -/* Execute specified askpass program and fetch password from standard - output. Return NULL on failure, otherwise a pointer to the data - read (which must be freed by caller) */ - -char * -askpass(char *askpass, const char *msg) -{ - pid_t pid; - size_t len; - char *pass; - int p[2], status, ret; - char buf[1024]; - int devnull; - - if (fflush(stdout) != 0) - error("askpass: fflush: %s", strerror(errno)); - assert(askpass != NULL); - if (pipe(p) < 0) - { - error("askpass: pipe: %s", strerror(errno)); - return NULL; - } - - pid = fork(); - switch (pid) - { - case -1: - error("askpass: fork: %s", strerror(errno)); - return NULL; - break; - case 0: - /* Child */ - seteuid(getuid()); - setuid(getuid()); - /* Close read end */ - close(p[0]); - - /* Setup stdin */ - devnull = open("/dev/null", 0, O_RDONLY); - if (dup2(devnull, STDIN_FILENO) < 0) - { - error("askpass: dup2: %s", strerror(errno)); - exit(1); - } - close(devnull); - - /* Setup stdout */ - if (dup2(p[1], STDOUT_FILENO) < 0) - { - error("askpass: dup2: %s", strerror(errno)); - exit(1); - } - close(p[1]); - - /* By now, the following fds are open: - 0 -> /dev/null - 1 -> pipe write end - 2 -> users terminal */ - execlp(askpass, askpass, msg, (char *) 0); - error("askpass: exec(%s): %s", askpass, strerror(errno)); - exit(1); - break; - default: - /* Parent */ - break; - } - /* Close write end */ - close(p[1]); - - len = ret = 0; - do - { - ret = read(p[0], buf + len, sizeof(buf) - 1 - len); - - if (ret == -1 && errno == EINTR) - continue; - if (ret <= 0) - break; - - len += ret; - } - while (sizeof(buf) - 1 - len > 0); - - - buf[len] = '\0'; - - close(p[0]); - while (waitpid(pid, &status, 0) < 0) - if (errno != EINTR) - break; - - if (WIFEXITED(status)) - { - if (WEXITSTATUS(status)) - { - error("askpass program returned %d\n", WEXITSTATUS(status)); - return NULL; - } - } - else - { - error("abnormal exit from askpass program"); - return NULL; - } - - buf[strcspn(buf, "\r\n")] = '\0'; - pass = strdup(buf); - memset(buf, 0, sizeof(buf)); - return pass; -}