1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-08-08 19:02:06 +03:00

misc: Remove session from ssh_get_local_username().

This commit is contained in:
Andreas Schneider
2011-08-16 22:24:31 +02:00
parent 1a0fbedc2e
commit ddcb88070b
4 changed files with 20 additions and 24 deletions

View File

@@ -25,7 +25,7 @@
/* in misc.c */
/* gets the user home dir. */
char *ssh_get_user_home_dir(void);
char *ssh_get_local_username(ssh_session session);
char *ssh_get_local_username(void);
int ssh_file_readaccess_ok(const char *file);
char *ssh_path_expand_tilde(const char *d);

View File

@@ -138,7 +138,7 @@ int gettimeofday(struct timeval *__p, void *__t) {
return (0);
}
char *ssh_get_local_username(ssh_session session) {
char *ssh_get_local_username(void) {
DWORD size = 0;
char *user;
@@ -147,7 +147,6 @@ char *ssh_get_local_username(ssh_session session) {
user = (char *) malloc(size);
if (user == NULL) {
ssh_set_error_oom(session);
return NULL;
}
@@ -233,7 +232,7 @@ int ssh_file_readaccess_ok(const char *file) {
return 1;
}
char *ssh_get_local_username(ssh_session session) {
char *ssh_get_local_username(void) {
struct passwd pwd;
struct passwd *pwdbuf;
char buf[NSS_BUFLEN_PASSWD];
@@ -242,15 +241,12 @@ char *ssh_get_local_username(ssh_session session) {
rc = getpwuid_r(getuid(), &pwd, buf, NSS_BUFLEN_PASSWD, &pwdbuf);
if (rc != 0) {
ssh_set_error(session, SSH_FATAL,
"Couldn't retrieve information for current user!");
return NULL;
}
name = strdup(pwd.pw_name);
if (name == NULL) {
ssh_set_error_oom(session);
return NULL;
}
@@ -724,7 +720,7 @@ char *ssh_path_expand_escape(ssh_session session, const char *s) {
x = strdup(session->sshdir);
break;
case 'u':
x = ssh_get_local_username(session);
x = ssh_get_local_username();
break;
case 'l':
if (gethostname(host, sizeof(host) == 0)) {

View File

@@ -457,7 +457,7 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type,
case SSH_OPTIONS_USER:
SAFE_FREE(session->username);
if (value == NULL) { /* set default username */
q = ssh_get_local_username(session);
q = ssh_get_local_username();
if (q == NULL) {
return -1;
}

View File

@@ -1247,7 +1247,7 @@ int ssh_publickey_to_file(ssh_session session, const char *file,
return SSH_ERROR;
}
user = ssh_get_local_username(session);
user = ssh_get_local_username();
if (user == NULL) {
SAFE_FREE(pubkey_64);
return SSH_ERROR;