(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:
Johan Danielsson
1999-08-19 09:51:22 +00:00
parent 9c6471334e
commit 15171c7b29

View File

@@ -391,6 +391,7 @@ main(int argc, char **argv)
/* reply(220,) must follow */ /* reply(220,) must follow */
} }
gethostname(hostname, sizeof(hostname)); gethostname(hostname, sizeof(hostname));
reply(220, "%s FTP server (%s" reply(220, "%s FTP server (%s"
#ifdef KRB5 #ifdef KRB5
"+%s" "+%s"
@@ -406,6 +407,7 @@ main(int argc, char **argv)
,krb4_version ,krb4_version
#endif #endif
); );
setjmp(errcatch); setjmp(errcatch);
for (;;) for (;;)
yyparse(); yyparse();
@@ -694,6 +696,25 @@ checkaccess(char *name)
#undef ALLOWED #undef ALLOWED
#undef NOT_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) int do_login(int code, char *passwd)
{ {
FILE *fd; FILE *fd;
@@ -750,12 +771,14 @@ int do_login(int code, char *passwd)
} }
} }
if (guest) { if (guest) {
show_issue(code);
reply(code, "Guest login ok, access restrictions apply."); reply(code, "Guest login ok, access restrictions apply.");
#ifdef HAVE_SETPROCTITLE #ifdef HAVE_SETPROCTITLE
snprintf (proctitle, sizeof(proctitle), snprintf (proctitle, sizeof(proctitle),
"%s: anonymous/%s", "%s: anonymous/%s",
remotehost, remotehost,
passwd); passwd);
setproctitle(proctitle);
#endif /* HAVE_SETPROCTITLE */ #endif /* HAVE_SETPROCTITLE */
if (logging) { if (logging) {
char data_addr[256]; char data_addr[256];
@@ -772,6 +795,7 @@ int do_login(int code, char *passwd)
passwd); passwd);
} }
} else { } else {
show_issue(code);
reply(code, "User %s logged in.", pw->pw_name); reply(code, "User %s logged in.", pw->pw_name);
#ifdef HAVE_SETPROCTITLE #ifdef HAVE_SETPROCTITLE
snprintf(proctitle, sizeof(proctitle), "%s: %s", remotehost, pw->pw_name); snprintf(proctitle, sizeof(proctitle), "%s: %s", remotehost, pw->pw_name);
@@ -1291,30 +1315,24 @@ send_data(FILE *instr, FILE *outstr)
struct stat st; struct stat st;
char *chunk; char *chunk;
int in = fileno(instr); 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. * mmap zero bytes has potential of loosing, don't do it.
*/ */
if (st.st_size > 0) {
chunk = mmap(0, st.st_size, PROT_READ, chunk = mmap(0, st.st_size, PROT_READ,
MAP_SHARED, in, 0); MAP_SHARED, in, 0);
if((void *)chunk != (void *)MAP_FAILED) { if((void *)chunk != (void *)MAP_FAILED) {
cnt = st.st_size - restart_point; cnt = st.st_size - restart_point;
sec_write(fileno(outstr), sec_write(fileno(outstr), chunk + restart_point, cnt);
chunk + restart_point,
cnt);
if (munmap(chunk, st.st_size) < 0) if (munmap(chunk, st.st_size) < 0)
warn ("munmap"); warn ("munmap");
sec_fflush(outstr); sec_fflush(outstr);
byte_count = cnt; byte_count = cnt;
transflag = 0; transflag = 0;
} }
} else {
transflag = 0;
} }
} }
}
#endif #endif
if(transflag) { if(transflag) {
struct stat st; struct stat st;