- (djm) Clean up. Strip some unnecessary differences with OpenBSD's code,

tidy necessary differences. Use Markus' new debugN() in entropy.c
This commit is contained in:
Damien Miller 2000-09-29 12:12:36 +11:00
parent 280e71bcb6
commit cb5e44a440
8 changed files with 57 additions and 71 deletions

View File

@ -2,6 +2,8 @@
- (djm) Fix SSH2 not terminating until all background tasks done problem.
- (djm) Another off-by-one fix from Pavel Kankovsky
<peak@argo.troja.mff.cuni.cz>
- (djm) Clean up. Strip some unnecessary differences with OpenBSD's code,
tidy necessary differences. Use Markus' new debugN() in entropy.c
20000926
- (djm) Update X11-askpass to 1.0.2 in RPM spec file

View File

@ -479,9 +479,9 @@ load_private_key(const char *filename, const char *passphrase, Key *key,
if (fd < 0)
return 0;
/* check owner and modes. */
/* check owner and modes */
#ifdef HAVE_CYGWIN
if (check_ntsec(filename))
if (check_ntsec(filename))
#endif
if (fstat(fd, &st) < 0 ||
(st.st_uid != 0 && st.st_uid != getuid()) ||

View File

@ -1763,7 +1763,8 @@ x11_create_display_inet(int screen_number, int x11_display_offset)
error("socket: %.100s", strerror(errno));
return NULL;
} else {
debug("Socket family %d not supported [X11 disp create]", ai->ai_family);
debug("x11_create_display_inet: Socket family %d not supported",
ai->ai_family);
continue;
}
}

View File

@ -35,15 +35,12 @@
# include <floatingpoint.h>
#endif /* HAVE_FLOATINGPOINT_H */
RCSID("$Id: entropy.c,v 1.19 2000/09/16 05:09:28 djm Exp $");
RCSID("$Id: entropy.c,v 1.20 2000/09/29 01:12:36 djm Exp $");
#ifndef offsetof
# define offsetof(type, member) ((size_t) &((type *)0)->member)
#endif
/* Print lots of detail */
/* #define DEBUG_ENTROPY */
/* Number of times to pass through command list gathering entropy */
#define NUM_ENTROPY_RUNS 1
@ -272,10 +269,8 @@ stir_from_programs(void)
/* Stir it in */
RAND_add(hash, sizeof(hash), entropy_estimate);
#ifdef DEBUG_ENTROPY
debug("Got %0.2f bytes of entropy from '%s'", entropy_estimate,
debug3("Got %0.2f bytes of entropy from '%s'", entropy_estimate,
entropy_sources[c].cmdstring);
#endif
total_entropy_estimate += entropy_estimate;
@ -285,10 +280,8 @@ stir_from_programs(void)
total_entropy_estimate += stir_rusage(RUSAGE_SELF, 0.1);
total_entropy_estimate += stir_rusage(RUSAGE_CHILDREN, 0.1);
} else {
#ifdef DEBUG_ENTROPY
debug("Command '%s' disabled (badness %d)",
debug2("Command '%s' disabled (badness %d)",
entropy_sources[c].cmdstring, entropy_sources[c].badness);
#endif
if (entropy_sources[c].badness > 0)
entropy_sources[c].badness--;
@ -373,6 +366,8 @@ hash_output_from_command(entropy_source_t *src, char *hash)
int total_bytes_read;
SHA_CTX sha;
debug3("Reading output from \'%s\'", src->cmdstring);
if (devnull == -1) {
devnull = open("/dev/null", O_RDWR);
if (devnull == -1)
@ -470,12 +465,10 @@ hash_output_from_command(entropy_source_t *src, char *hash)
close(p[0]);
#ifdef DEBUG_ENTROPY
debug("Time elapsed: %d msec", msec_elapsed);
#endif
debug3("Time elapsed: %d msec", msec_elapsed);
if (waitpid(pid, &status, 0) == -1) {
debug("Couldn't wait for child '%s' completion: %s", src->cmdstring,
error("Couldn't wait for child '%s' completion: %s", src->cmdstring,
strerror(errno));
return(0.0);
}
@ -486,7 +479,7 @@ hash_output_from_command(entropy_source_t *src, char *hash)
/* closing p[0] on timeout causes the entropy command to
* SIGPIPE. Take whatever output we got, and mark this command
* as slow */
debug("Command '%s' timed out", src->cmdstring);
debug2("Command '%s' timed out", src->cmdstring);
src->sticky_badness *= 2;
src->badness = src->sticky_badness;
return(total_bytes_read);
@ -496,13 +489,13 @@ hash_output_from_command(entropy_source_t *src, char *hash)
if (WEXITSTATUS(status)==0) {
return(total_bytes_read);
} else {
debug("Command '%s' exit status was %d", src->cmdstring,
debug2("Command '%s' exit status was %d", src->cmdstring,
WEXITSTATUS(status));
src->badness = src->sticky_badness = 128;
return (0.0);
}
} else if (WIFSIGNALED(status)) {
debug("Command '%s' returned on uncaught signal %d !", src->cmdstring,
debug2("Command '%s' returned on uncaught signal %d !", src->cmdstring,
status);
src->badness = src->sticky_badness = 128;
return(0.0);

20
rsa.c
View File

@ -82,21 +82,6 @@ rsa_alive()
return (1);
}
/*
* Key generation progress meter callback
*/
void
keygen_progress(int p, int n, void *arg)
{
const char progress_chars[] = ".o+O?";
if ((p < 0) || (p > (sizeof(progress_chars) - 2)))
p = sizeof(progress_chars) - 2;
putchar(progress_chars[p]);
fflush(stdout);
}
/*
* Generates RSA public and private keys. This initializes the data
* structures; they should be freed with rsa_clear_private_key and
@ -113,11 +98,8 @@ rsa_generate_key(RSA *prv, RSA *pub, unsigned int bits)
if (rsa_verbose) {
printf("Generating RSA keys: ");
fflush(stdout);
key = RSA_generate_key(bits, 35, keygen_progress, NULL);
printf("\n");
} else {
key = RSA_generate_key(bits, 35, NULL, NULL);
}
key = RSA_generate_key(bits, 35, NULL, NULL);
if (key == NULL)
fatal("rsa_generate_key: key generation failed.");

View File

@ -867,7 +867,7 @@ void do_pam_environment(char ***env, int *envsize)
strncpy(var_name, pam_env[i], equals - pam_env[i]);
strcpy(var_val, equals + 1);
debug("PAM environment: %s=%s", var_name, var_val);
debug3("PAM environment: %s=%s", var_name, var_val);
child_set_env(env, envsize, var_name, var_val);
}
@ -875,6 +875,32 @@ void do_pam_environment(char ***env, int *envsize)
}
#endif /* USE_PAM */
#ifdef HAVE_CYGWIN
void copy_environment(char ***env, int *envsize)
{
char *equals, var_name[512], var_val[512];
int i;
for(i = 0; environ[i] != NULL; i++) {
if ((equals = strstr(environ[i], "=")) == NULL)
continue;
if (strlen(environ[i]) < (sizeof(var_name) - 1)) {
memset(var_name, '\0', sizeof(var_name));
memset(var_val, '\0', sizeof(var_val));
strncpy(var_name, environ[i], equals - environ[i]);
strcpy(var_val, equals + 1);
debug3("Copy environment: %s=%s", var_name, var_val);
child_set_env(env, envsize, var_name, var_val);
}
}
}
#endif
#if defined(HAVE_GETUSERATTR)
/*
* AIX-specific login initialisation
@ -1107,15 +1133,7 @@ do_child(const char *command, struct passwd * pw, const char *term,
* The Windows environment contains some setting which are
* important for a running system. They must not be dropped.
*/
{
char **ep;
for (ep = environ; *ep; ++ep) {
char *esp = strchr(*ep, '=');
*esp = '\0';
child_set_env(&env, &envsize, *ep, esp + 1);
*esp = '=';
}
}
copy_environment(&env, &envsize);
#endif
if (!options.use_login) {
@ -1126,8 +1144,8 @@ do_child(const char *command, struct passwd * pw, const char *term,
#ifdef HAVE_LOGIN_CAP
(void) setusercontext(lc, pw, pw->pw_uid, LOGIN_SETPATH);
child_set_env(&env, &envsize, "PATH", getenv("PATH"));
#else
#ifndef HAVE_CYGWIN
#else /* HAVE_LOGIN_CAP */
# ifndef HAVE_CYGWIN
/*
* There's no standard path on Windows. The path contains
* important components pointing to the system directories,
@ -1135,8 +1153,8 @@ do_child(const char *command, struct passwd * pw, const char *term,
* remains intact here.
*/
child_set_env(&env, &envsize, "PATH", _PATH_STDPATH);
#endif
#endif
# endif /* HAVE_CYGWIN */
#endif /* HAVE_LOGIN_CAP */
snprintf(buf, sizeof buf, "%.200s/%.50s",
_PATH_MAILDIR, pw->pw_name);
@ -1178,15 +1196,11 @@ do_child(const char *command, struct passwd * pw, const char *term,
original_command);
#ifdef _AIX
{
char *authstate,*krb5cc;
if ((authstate = getenv("AUTHSTATE")) != NULL)
child_set_env(&env,&envsize,"AUTHSTATE",authstate);
if ((krb5cc = getenv("KRB5CCNAME")) != NULL)
child_set_env(&env,&envsize,"KRB5CCNAME",krb5cc);
}
if ((cp = getenv("AUTHSTATE")) != NULL)
child_set_env(&env, &envsize, "AUTHSTATE", cp);
if ((cp = getenv("KRB5CCNAME")) != NULL)
child_set_env(&env, &envsize, "KRB5CCNAME", cp);
read_environment_file(&env, &envsize, "/etc/environment");
#endif
#ifdef KRB4
@ -1203,8 +1217,6 @@ do_child(const char *command, struct passwd * pw, const char *term,
do_pam_environment(&env, &envsize);
#endif /* USE_PAM */
read_environment_file(&env,&envsize,"/etc/environment");
if (xauthfile)
child_set_env(&env, &envsize, "XAUTHORITY", xauthfile);
if (auth_get_socket_name() != NULL)
@ -1313,13 +1325,11 @@ do_child(const char *command, struct passwd * pw, const char *term,
"Running %.100s add %.100s %.100s %.100s\n",
options.xauth_location, display,
auth_proto, auth_data);
#ifndef HAVE_CYGWIN
if (screen != NULL)
fprintf(stderr,
"Adding %.*s/unix%s %s %s\n",
(int)(screen-display), display,
screen, auth_proto, auth_data);
#endif
}
snprintf(cmd, sizeof cmd, "%s -q -",
options.xauth_location);
@ -1327,12 +1337,10 @@ do_child(const char *command, struct passwd * pw, const char *term,
if (f) {
fprintf(f, "add %s %s %s\n", display,
auth_proto, auth_data);
#ifndef HAVE_CYGWIN
if (screen != NULL)
fprintf(f, "add %.*s/unix%s %s %s\n",
(int)(screen-display), display,
screen, auth_proto, auth_data);
#endif
pclose(f);
} else {
fprintf(stderr, "Could not run %s\n",

4
ssh.c
View File

@ -485,11 +485,11 @@ main(int ac, char **av)
if (!host)
usage();
SSLeay_add_all_algorithms();
/* Initialize the command to execute on remote host. */
buffer_init(&command);
SSLeay_add_all_algorithms();
/*
* Save the command to execute on the remote host in a buffer. There
* is no limit on the length of the command, except by the maximum

View File

@ -1 +1 @@
#define SSH_VERSION "OpenSSH_2.2.0p1"
#define SSH_VERSION "OpenSSH_2.2.0p2"