(do_login): show issue-file
(send_data): change handling of zero-byte files git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@6836 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -391,6 +391,7 @@ main(int argc, char **argv)
|
||||
/* reply(220,) must follow */
|
||||
}
|
||||
gethostname(hostname, sizeof(hostname));
|
||||
|
||||
reply(220, "%s FTP server (%s"
|
||||
#ifdef KRB5
|
||||
"+%s"
|
||||
@@ -406,6 +407,7 @@ main(int argc, char **argv)
|
||||
,krb4_version
|
||||
#endif
|
||||
);
|
||||
|
||||
setjmp(errcatch);
|
||||
for (;;)
|
||||
yyparse();
|
||||
@@ -694,6 +696,25 @@ checkaccess(char *name)
|
||||
#undef ALLOWED
|
||||
#undef NOT_ALLOWED
|
||||
|
||||
/* output contents of /etc/issue.net, or /etc/issue */
|
||||
static void
|
||||
show_issue(int code)
|
||||
{
|
||||
FILE *f;
|
||||
char buf[128];
|
||||
|
||||
f = fopen("/etc/issue.net", "r");
|
||||
if(f == NULL)
|
||||
f = fopen("/etc/issue", "r");
|
||||
if(f){
|
||||
while(fgets(buf, sizeof(buf), f)){
|
||||
buf[strcspn(buf, "\r\n")] = '\0';
|
||||
lreply(code, buf, strlen(buf));
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
|
||||
int do_login(int code, char *passwd)
|
||||
{
|
||||
FILE *fd;
|
||||
@@ -750,12 +771,14 @@ int do_login(int code, char *passwd)
|
||||
}
|
||||
}
|
||||
if (guest) {
|
||||
show_issue(code);
|
||||
reply(code, "Guest login ok, access restrictions apply.");
|
||||
#ifdef HAVE_SETPROCTITLE
|
||||
snprintf (proctitle, sizeof(proctitle),
|
||||
"%s: anonymous/%s",
|
||||
remotehost,
|
||||
passwd);
|
||||
setproctitle(proctitle);
|
||||
#endif /* HAVE_SETPROCTITLE */
|
||||
if (logging) {
|
||||
char data_addr[256];
|
||||
@@ -772,6 +795,7 @@ int do_login(int code, char *passwd)
|
||||
passwd);
|
||||
}
|
||||
} else {
|
||||
show_issue(code);
|
||||
reply(code, "User %s logged in.", pw->pw_name);
|
||||
#ifdef HAVE_SETPROCTITLE
|
||||
snprintf(proctitle, sizeof(proctitle), "%s: %s", remotehost, pw->pw_name);
|
||||
@@ -1291,30 +1315,24 @@ send_data(FILE *instr, FILE *outstr)
|
||||
struct stat st;
|
||||
char *chunk;
|
||||
int in = fileno(instr);
|
||||
if(fstat(in, &st) == 0 && S_ISREG(st.st_mode)) {
|
||||
if(fstat(in, &st) == 0 && S_ISREG(st.st_mode)
|
||||
&& st.st_size > 0) {
|
||||
/*
|
||||
* mmap zero bytes has potential of loosing, don't do it.
|
||||
*/
|
||||
if (st.st_size > 0) {
|
||||
chunk = mmap(0, st.st_size, PROT_READ,
|
||||
MAP_SHARED, in, 0);
|
||||
if((void *)chunk != (void *)MAP_FAILED) {
|
||||
cnt = st.st_size - restart_point;
|
||||
sec_write(fileno(outstr),
|
||||
chunk + restart_point,
|
||||
cnt);
|
||||
sec_write(fileno(outstr), chunk + restart_point, cnt);
|
||||
if (munmap(chunk, st.st_size) < 0)
|
||||
warn ("munmap");
|
||||
sec_fflush(outstr);
|
||||
byte_count = cnt;
|
||||
transflag = 0;
|
||||
}
|
||||
} else {
|
||||
transflag = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
if(transflag) {
|
||||
struct stat st;
|
||||
|
Reference in New Issue
Block a user