remove pointless dependency on passwd, and now it "actually works"!

sigsegv_dump
Greg Alexander 9 years ago
parent 8fb9669531
commit 0ad7144d15

@ -35,16 +35,8 @@ cleanup_exit(int i)
int
main(int argc, char **argv)
{
struct passwd *user_pw;
/* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
sanitise_stdfd();
if ((user_pw = getpwuid(getuid())) == NULL) {
fprintf(stderr, "No user found for uid %lu\n",
(u_long)getuid());
return 1;
}
return (sftp_server_main(argc, argv, user_pw));
return (sftp_server_main(argc, argv));
}

@ -33,11 +33,9 @@
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <pwd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <pwd.h>
#include <time.h>
#include <unistd.h>
#include <stdarg.h>
@ -56,7 +54,6 @@
#define get_string(lenp) buffer_get_string(&iqueue, lenp);
/* Our client */
static struct passwd *pw = NULL;
static char *client_addr = NULL;
/* input and output queue */
@ -1182,8 +1179,7 @@ process(void)
cp = buffer_ptr(&iqueue);
msg_len = get_u32(cp);
if (msg_len > SFTP_MAX_MSG_LENGTH) {
error("bad message from %s local user %s",
client_addr, pw->pw_name);
error("bad message from %s", client_addr);
sftp_server_cleanup_exit(11);
}
if (buf_len < msg_len + 4)
@ -1243,7 +1239,7 @@ sftp_server_cleanup_exit(int i)
}
int
sftp_server_main(int argc, char **argv, struct passwd *user_pw)
sftp_server_main(int argc, char **argv)
{
fd_set rsetx, wsetx;
fd_set *rset = &rsetx, *wset = &wsetx;
@ -1254,8 +1250,6 @@ sftp_server_main(int argc, char **argv, struct passwd *user_pw)
extern char *optarg;
pw = pwcopy(user_pw);
while (!skipargs && (ch = getopt(argc, argv,
"d:f:l:P:p:Q:u:cehR")) != -1) {
switch (ch) {
@ -1280,12 +1274,6 @@ sftp_server_main(int argc, char **argv, struct passwd *user_pw)
*/
skipargs = 1;
break;
case 'd':
cp = tilde_expand_filename(optarg, user_pw->pw_uid);
homedir = percent_expand(cp, "d", user_pw->pw_dir,
"u", user_pw->pw_name, (char *)NULL);
free(cp);
break;
case 'p':
if (request_whitelist != NULL)
fatal("Permitted requests already set");

@ -97,5 +97,5 @@
struct passwd;
int sftp_server_main(int, char **, struct passwd *);
int sftp_server_main(int, char **);
void sftp_server_cleanup_exit(int) __attribute__((noreturn));

Loading…
Cancel
Save