version 1.3, 1999/11/23 22:25:56 |
version 1.4, 1999/11/24 00:26:03 |
|
|
/* |
/* |
|
* 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 |
|
*/ |
|
|
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 |
|
|
|
*/ |
|
|
|
#include "includes.h" |
#include "includes.h" |
RCSID("$Id$"); |
RCSID("$Id$"); |
|
|
#include "xmalloc.h" |
#include "xmalloc.h" |
#include "ssh.h" |
#include "ssh.h" |
|
|
/* Expands tildes in the file name. Returns data allocated by xmalloc. |
/* |
Warning: this calls getpw*. */ |
* Expands tildes in the file name. Returns data allocated by xmalloc. |
|
* Warning: this calls getpw*. |
|
*/ |
char * |
char * |
tilde_expand_filename(const char *filename, uid_t my_uid) |
tilde_expand_filename(const char *filename, uid_t my_uid) |
{ |
{ |
|
|
/* Find where the username ends. */ |
/* Find where the username ends. */ |
cp = strchr(filename, '/'); |
cp = strchr(filename, '/'); |
if (cp) |
if (cp) |
userlen = cp - filename; /* Have something after username. */ |
userlen = cp - filename; /* Something after username. */ |
else |
else |
userlen = strlen(filename); /* Nothign after username. */ |
userlen = strlen(filename); /* Nothing after username. */ |
if (userlen == 0) |
if (userlen == 0) |
pw = getpwuid(my_uid); /* Own home directory. */ |
pw = getpwuid(my_uid); /* Own home directory. */ |
else { |
else { |