Remove -P (askpass program)
git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/trunk/rdesktop@212 423420c4-83ab-492f-b58f-81f9feb106b5
This commit is contained in:
parent
a3088b8a6c
commit
7f21b7e693
@ -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.
|
to setup a fixed environment for the user after logon.
|
||||||
.TP
|
.TP
|
||||||
.BR "-p <password>"
|
.BR "-p <password>"
|
||||||
The password to authenticate with, used in combination with -u for
|
The password to authenticate with. Use -p - to make rdesktop request a
|
||||||
autologon. Use -p - to make rdesktop request a password at startup.
|
password at startup (from standard input).
|
||||||
WARNING: the -p <password> option will be visible to all users when
|
WARNING: if you specify a password on the command line it may be visible
|
||||||
they use tools like ps. The -P option is safer.
|
to other users when they use tools like ps.
|
||||||
.TP
|
|
||||||
.BR "-P <program>"
|
|
||||||
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.
|
|
||||||
.TP
|
.TP
|
||||||
.BR "-n <name>"
|
.BR "-n <name>"
|
||||||
Client name. The default is the hostname.
|
Client name. The default is the hostname.
|
||||||
|
14
rdesktop.c
14
rdesktop.c
@ -60,7 +60,6 @@ usage(char *program)
|
|||||||
fprintf(stderr, " -s: shell\n");
|
fprintf(stderr, " -s: shell\n");
|
||||||
fprintf(stderr, " -c: working directory\n");
|
fprintf(stderr, " -c: working directory\n");
|
||||||
fprintf(stderr, " -p: password (- to prompt)\n");
|
fprintf(stderr, " -p: password (- to prompt)\n");
|
||||||
fprintf(stderr, " -P: askpass-program (autologon)\n");
|
|
||||||
fprintf(stderr, " -n: client hostname\n");
|
fprintf(stderr, " -n: client hostname\n");
|
||||||
fprintf(stderr, " -k: keyboard layout on terminal server (us,sv,gr etc.)\n");
|
fprintf(stderr, " -k: keyboard layout on terminal server (us,sv,gr etc.)\n");
|
||||||
fprintf(stderr, " -g: desktop geometry (WxH)\n");
|
fprintf(stderr, " -g: desktop geometry (WxH)\n");
|
||||||
@ -117,7 +116,6 @@ main(int argc, char *argv[])
|
|||||||
char fullhostname[64];
|
char fullhostname[64];
|
||||||
char domain[16];
|
char domain[16];
|
||||||
char password[16];
|
char password[16];
|
||||||
char *askpass_result;
|
|
||||||
char shell[32];
|
char shell[32];
|
||||||
char directory[32];
|
char directory[32];
|
||||||
BOOL prompt_password;
|
BOOL prompt_password;
|
||||||
@ -131,7 +129,7 @@ main(int argc, char *argv[])
|
|||||||
domain[0] = password[0] = shell[0] = directory[0] = 0;
|
domain[0] = password[0] = shell[0] = directory[0] = 0;
|
||||||
strcpy(keymapname, "us");
|
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)
|
switch (c)
|
||||||
{
|
{
|
||||||
@ -167,16 +165,6 @@ main(int argc, char *argv[])
|
|||||||
*(p++) = 'X';
|
*(p++) = 'X';
|
||||||
break;
|
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':
|
case 'n':
|
||||||
STRNCPY(hostname, optarg, sizeof(hostname));
|
STRNCPY(hostname, optarg, sizeof(hostname));
|
||||||
break;
|
break;
|
||||||
|
141
readpass.c
141
readpass.c
@ -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 <sys/types.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include "rdesktop.h"
|
|
||||||
#include <assert.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
|
|
||||||
/* 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;
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user