Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:hlin
opensuse
openssh-4.1p1-pwname-home.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File openssh-4.1p1-pwname-home.diff of Package opensuse
diff -dpru openssh-3.9p1~/misc.c openssh-3.9p1/misc.c --- openssh-3.9p1~/misc.c 2004-08-13 13:18:01.000000000 +0200 +++ openssh-3.9p1/misc.c 2005-08-15 20:04:01.000000000 +0200 @@ -147,6 +147,29 @@ strdelim(char **s) return (old); } +struct passwd *getpwuid_wh(uid_t uid) { + /* Return the password structure by lookup of the username in $ENV{USER}, + but only when the UID matches a lookup-by-uid so as to not allow using + another users' .ssh files in case this function be used in superuser + context. */ + + const char *user = getenv("USER"); + struct passwd *pe_nam, *pe_uid; + + if(user == NULL || (pe_nam = getpwnam(user)) == NULL) { + return getpwuid(uid); + } + + pe_nam = pwcopy(pe_nam); + if((pe_uid = getpwuid(uid)) == NULL || pe_nam->pw_uid != pe_uid->pw_uid) { + free(pe_nam); + return pe_uid; + } + + free(pe_nam); // - need to return a non-pwcopy struct + return getpwnam(user); +} + struct passwd * pwcopy(struct passwd *pw) { diff -dpru openssh-3.9p1~/misc.h openssh-3.9p1/misc.h --- openssh-3.9p1~/misc.h 2004-08-13 13:18:01.000000000 +0200 +++ openssh-3.9p1/misc.h 2005-08-15 20:00:24.000000000 +0200 @@ -24,6 +24,7 @@ char *cleanhostname(char *); char *colon(char *); long convtime(const char *); +struct passwd *getpwuid_wh(uid_t); struct passwd *pwcopy(struct passwd *); typedef struct arglist arglist; diff -dpru openssh-3.9p1~/ssh.c openssh-3.9p1/ssh.c --- openssh-3.9p1~/ssh.c 2005-08-15 19:33:34.000000000 +0200 +++ openssh-3.9p1/ssh.c 2005-08-15 20:00:31.000000000 +0200 @@ -213,7 +213,7 @@ main(int ac, char **av) } #endif /* Get user data. */ - pw = getpwuid(original_real_uid); + pw = getpwuid_wh(original_real_uid); if (!pw) { logit("You don't exist, go away!"); exit(1); diff -dpru openssh-3.9p1~/tildexpand.c openssh-3.9p1/tildexpand.c --- openssh-3.9p1~/tildexpand.c 2005-08-15 20:04:44.000000000 +0200 +++ openssh-3.9p1/tildexpand.c 2005-08-15 20:03:14.000000000 +0200 @@ -45,7 +45,7 @@ tilde_expand_filename(const char *filena else userlen = strlen(filename); /* Nothing after username. */ if (userlen == 0) - pw = getpwuid(my_uid); /* Own home directory. */ + pw = getpwuid_wh(my_uid); /* Own home directory. */ else { /* Tilde refers to someone elses home directory. */ if (userlen > sizeof(user) - 1)
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor