diff options
author | damien <damien> | 1999-11-24 13:26:21 +0000 |
---|---|---|
committer | damien <damien> | 1999-11-24 13:26:21 +0000 |
commit | f0dd0390ca88290603753fc726e644445d0fafa0 (patch) | |
tree | 042744f76f40a326b873cb1c3690a6d7d966bc3e /tildexpand.c | |
parent | 21a54ee8a519908cd642a17a8574e689528a03a0 (diff) | |
download | openssh-f0dd0390ca88290603753fc726e644445d0fafa0.tar.gz |
- Merged very large OpenBSD source code reformat
- OpenBSD CVS updates
- [channels.c cipher.c compat.c log-client.c scp.c serverloop.c]
[ssh.h sshd.8 sshd.c]
syslog changes:
* Unified Logmessage for all auth-types, for success and for failed
* Standard connections get only ONE line in the LOG when level==LOG:
Auth-attempts are logged only, if authentication is:
a) successfull or
b) with passwd or
c) we had more than AUTH_FAIL_LOG failues
* many log() became verbose()
* old behaviour with level=VERBOSE
- [readconf.c readconf.h ssh.1 ssh.h sshconnect.c sshd.c]
tranfer s/key challenge/response data in SSH_SMSG_AUTH_TIS_CHALLENGE
messages. allows use of s/key in windows (ttssh, securecrt) and
ssh-1.2.27 clients without 'ssh -v', ok: niels@
- [sshd.8]
-V, for fallback to openssh in SSH2 compatibility mode
- [sshd.c]
fix sigchld race; cjc5@po.cwru.edu
Diffstat (limited to 'tildexpand.c')
-rw-r--r-- | tildexpand.c | 114 |
1 files changed, 53 insertions, 61 deletions
diff --git a/tildexpand.c b/tildexpand.c index e4b57091..92422ee3 100644 --- a/tildexpand.c +++ b/tildexpand.c @@ -1,70 +1,62 @@ /* - -tildexpand.c - -Author: Tatu Ylonen <ylo@cs.hut.fi> - -Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland - All rights reserved - -Created: Wed Jul 12 01:07:36 1995 ylo - -*/ + * Author: Tatu Ylonen <ylo@cs.hut.fi> + * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland + * All rights reserved + * Created: Wed Jul 12 01:07:36 1995 ylo + */ #include "includes.h" -RCSID("$Id: tildexpand.c,v 1.1 1999/10/27 03:42:46 damien Exp $"); +RCSID("$Id: tildexpand.c,v 1.2 1999/11/24 13:26:23 damien Exp $"); #include "xmalloc.h" #include "ssh.h" -/* Expands tildes in the file name. Returns data allocated by xmalloc. - Warning: this calls getpw*. */ - -char *tilde_expand_filename(const char *filename, uid_t my_uid) +/* + * Expands tildes in the file name. Returns data allocated by xmalloc. + * Warning: this calls getpw*. + */ +char * +tilde_expand_filename(const char *filename, uid_t my_uid) { - const char *cp; - unsigned int userlen; - char *expanded; - struct passwd *pw; - char user[100]; - - /* Return immediately if no tilde. */ - if (filename[0] != '~') - return xstrdup(filename); - - /* Skip the tilde. */ - filename++; - - /* Find where the username ends. */ - cp = strchr(filename, '/'); - if (cp) - userlen = cp - filename; /* Have something after username. */ - else - userlen = strlen(filename); /* Nothign after username. */ - if (userlen == 0) - pw = getpwuid(my_uid); /* Own home directory. */ - else - { - /* Tilde refers to someone elses home directory. */ - if (userlen > sizeof(user) - 1) - fatal("User name after tilde too long."); - memcpy(user, filename, userlen); - user[userlen] = 0; - pw = getpwnam(user); - } - - /* Check that we found the user. */ - if (!pw) - fatal("Unknown user %100s.", user); - - /* If referring to someones home directory, return it now. */ - if (!cp) - { /* Only home directory specified */ - return xstrdup(pw->pw_dir); - } - - /* Build a path combining the specified directory and path. */ - expanded = xmalloc(strlen(pw->pw_dir) + strlen(cp + 1) + 2); - sprintf(expanded, "%s/%s", pw->pw_dir, cp + 1); - return expanded; + const char *cp; + unsigned int userlen; + char *expanded; + struct passwd *pw; + char user[100]; + + /* Return immediately if no tilde. */ + if (filename[0] != '~') + return xstrdup(filename); + + /* Skip the tilde. */ + filename++; + + /* Find where the username ends. */ + cp = strchr(filename, '/'); + if (cp) + userlen = cp - filename; /* Something after username. */ + else + userlen = strlen(filename); /* Nothing after username. */ + if (userlen == 0) + pw = getpwuid(my_uid); /* Own home directory. */ + else { + /* Tilde refers to someone elses home directory. */ + if (userlen > sizeof(user) - 1) + fatal("User name after tilde too long."); + memcpy(user, filename, userlen); + user[userlen] = 0; + pw = getpwnam(user); + } + /* Check that we found the user. */ + if (!pw) + fatal("Unknown user %100s.", user); + + /* If referring to someones home directory, return it now. */ + if (!cp) { /* Only home directory specified */ + return xstrdup(pw->pw_dir); + } + /* Build a path combining the specified directory and path. */ + expanded = xmalloc(strlen(pw->pw_dir) + strlen(cp + 1) + 2); + sprintf(expanded, "%s/%s", pw->pw_dir, cp + 1); + return expanded; } |