diff options
author | Hans Insulander <hin@cvs.openbsd.org> | 2000-07-11 09:19:28 +0000 |
---|---|---|
committer | Hans Insulander <hin@cvs.openbsd.org> | 2000-07-11 09:19:28 +0000 |
commit | f3f6b6bb6bcb9c2d959e8209de48cdaac140c8bd (patch) | |
tree | d74b91c0650b086b2c647b9195d05776584d56b4 | |
parent | 28a4cae812f49405f5cf67b75420db2c93bc6789 (diff) |
Merge in KTH Kerberos4 1.0.2
-rw-r--r-- | kerberosIV/src/appl/bsd/rshd.c | 18 | ||||
-rw-r--r-- | kerberosIV/src/appl/ftp/ftpd/ftpd.c | 110 | ||||
-rw-r--r-- | kerberosIV/src/appl/kauth/kauthd.c | 2 | ||||
-rw-r--r-- | kerberosIV/src/appl/sample/sample_server.c | 2 |
4 files changed, 64 insertions, 68 deletions
diff --git a/kerberosIV/src/appl/bsd/rshd.c b/kerberosIV/src/appl/bsd/rshd.c index bf9cc4f3709..973c20a0e29 100644 --- a/kerberosIV/src/appl/bsd/rshd.c +++ b/kerberosIV/src/appl/bsd/rshd.c @@ -42,7 +42,7 @@ #include "bsd_locl.h" -RCSID("$KTH: rshd.c,v 1.60 1999/11/13 06:13:53 assar Exp $"); +RCSID("$KTH: rshd.c,v 1.60.2.1 2000/06/23 02:40:54 assar Exp $"); extern char *__rcmd_errstr; /* syslog hook from libc/net/rcmd.c. */ extern int __check_rhosts_file; @@ -200,6 +200,8 @@ doit(struct sockaddr_in *fromp) char *cp, sig, buf[DES_RW_MAXWRITE]; char cmdbuf[NCARGS+1], locuser[16], remuser[16]; char remotehost[2 * MaxHostNameLen + 1]; + uid_t uid; + char shell_path[MAXPATHLEN]; AUTH_DAT *kdata; KTEXT ticket; @@ -571,14 +573,16 @@ doit(struct sockaddr_in *fromp) snprintf(path, sizeof(path), "PATH=%s:%s", BINDIR, _PATH_DEFPATH); strlcat(shell, pwd->pw_shell, sizeof(shell)); + strlcpy(shell_path, pwd->pw_shell, sizeof(shell_path)); strlcat(username, pwd->pw_name, sizeof(username)); + uid = pwd->pw_uid; cp = strrchr(pwd->pw_shell, '/'); if (cp) cp++; else cp = pwd->pw_shell; endpwent(); - if (log_success || pwd->pw_uid == 0) { + if (log_success || uid == 0) { if (use_kerberos) syslog(LOG_INFO|LOG_AUTH, "Kerberos shell from %s on %s as %s, cmd='%.80s'", @@ -591,12 +595,16 @@ doit(struct sockaddr_in *fromp) remuser, remotehost, locuser, cmdbuf); } if (k_hasafs()) { + char cell[64]; + if (new_pag) k_setpag(); /* Put users process in an new pag */ - krb_afslog(0, 0); + if (k_afs_cell_of_file (homedir, cell, sizeof(cell)) == 0) + krb_afslog_uid_home (cell, NULL, uid, homedir); + krb_afslog_uid_home(NULL, NULL, uid, homedir); } - execle(pwd->pw_shell, cp, "-c", cmdbuf, 0, envinit); - err(1, "%s", pwd->pw_shell); + execle(shell_path, cp, "-c", cmdbuf, 0, envinit); + err(1, "%s", shell_path); } /* diff --git a/kerberosIV/src/appl/ftp/ftpd/ftpd.c b/kerberosIV/src/appl/ftp/ftpd/ftpd.c index a7627e3dc91..44bbd5f94c3 100644 --- a/kerberosIV/src/appl/ftp/ftpd/ftpd.c +++ b/kerberosIV/src/appl/ftp/ftpd/ftpd.c @@ -38,7 +38,7 @@ #endif #include "getarg.h" -RCSID("$KTH: ftpd.c,v 1.131 1999/11/30 19:18:38 assar Exp $"); +RCSID("$KTH: ftpd.c,v 1.131.2.3 2000/06/23 02:49:48 assar Exp $"); static char version[] = "Version 6.00"; @@ -195,14 +195,13 @@ parse_auth_level(char *str) * Print usage and die. */ -static int debug_flag; static int interactive_flag; static char *guest_umask_string; static char *port_string; static char *umask_string; static char *auth_string; -int use_builtin_ls; +int use_builtin_ls = -1; static int help_flag; static int version_flag; @@ -216,8 +215,8 @@ struct getargs args[] = { { NULL, 't', arg_integer, &ftpd_timeout, "initial timeout" }, { NULL, 'T', arg_integer, &maxtimeout, "max timeout" }, { NULL, 'u', arg_string, &umask_string, "umask for user logins" }, - { NULL, 'd', arg_flag, &debug_flag, "enable debugging" }, - { NULL, 'v', arg_flag, &debug_flag, "enable debugging" }, + { NULL, 'd', arg_flag, &debug, "enable debugging" }, + { NULL, 'v', arg_flag, &debug, "enable debugging" }, { "builtin-ls", 'B', arg_flag, &use_builtin_ls, "use built-in ls to list files" }, { "version", 0, arg_flag, &version_flag }, { "help", 'h', arg_flag, &help_flag } @@ -232,6 +231,24 @@ usage (int code) exit (code); } +/* output contents of a file */ +static int +show_file(const char *file, int code) +{ + FILE *f; + char buf[128]; + + f = fopen(file, "r"); + if(f == NULL) + return -1; + while(fgets(buf, sizeof(buf), f)){ + buf[strcspn(buf, "\r\n")] = '\0'; + lreply(code, "%s", buf); + } + fclose(f); + return 0; +} + int main(int argc, char **argv) { @@ -377,27 +394,12 @@ main(int argc, char **argv) tmpline[0] = '\0'; /* If logins are disabled, print out the message. */ - if ((fd = fopen(_PATH_NOLOGIN,"r")) != NULL) { - while (fgets(line, sizeof(line), fd) != NULL) { - if ((cp = strchr(line, '\n')) != NULL) - *cp = '\0'; - lreply(530, "%s", line); - } - fflush(stdout); - fclose(fd); + if(show_file(_PATH_NOLOGIN, 530) == 0) { reply(530, "System not available."); exit(0); } - if ((fd = fopen(_PATH_FTPWELCOME, "r")) != NULL) { - while (fgets(line, sizeof(line), fd) != NULL) { - if ((cp = strchr(line, '\n')) != NULL) - *cp = '\0'; - lreply(220, "%s", line); - } - fflush(stdout); - fclose(fd); - /* reply(220,) must follow */ - } + show_file(_PATH_FTPWELCOME, 220); + /* reply(220,) must follow */ gethostname(hostname, sizeof(hostname)); reply(220, "%s FTP server (%s" @@ -704,24 +706,6 @@ 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, "%s", buf); - } - fclose(f); - } -} int do_login(int code, char *passwd) { @@ -765,21 +749,26 @@ int do_login(int code, char *passwd) reply(550, "Can't set uid."); return -1; } + + if(use_builtin_ls == -1) { + struct stat st; + /* if /bin/ls exist and is a regular file, use it, otherwise + use built-in ls */ + if(stat("/bin/ls", &st) == 0 && + S_ISREG(st.st_mode)) + use_builtin_ls = 0; + else + use_builtin_ls = 1; + } + /* * Display a login message, if it exists. * N.B. reply(code,) must follow the message. */ - if ((fd = fopen(_PATH_FTPLOGINMESG, "r")) != NULL) { - char *cp, line[LINE_MAX]; - - while (fgets(line, sizeof(line), fd) != NULL) { - if ((cp = strchr(line, '\n')) != NULL) - *cp = '\0'; - lreply(code, "%s", line); - } - } + show_file(_PATH_FTPLOGINMESG, code); + if(show_file(_PATH_ISSUE_NET, code) != 0) + show_file(_PATH_ISSUE, code); if (guest) { - show_issue(code); reply(code, "Guest login ok, access restrictions apply."); #ifdef HAVE_SETPROCTITLE snprintf (proctitle, sizeof(proctitle), @@ -803,7 +792,6 @@ 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); @@ -957,8 +945,8 @@ retrieve(const char *cmd, char *name) {".tar", "/bin/gtar cPf - %s", NULL}, {".tar.gz", "/bin/gtar zcPf - %s", NULL}, {".tar.Z", "/bin/gtar ZcPf - %s", NULL}, - {".gz", "/bin/gzip -c %s", "/bin/gzip -c -d %s"}, - {".Z", "/bin/compress -c %s", "/bin/uncompress -c -d %s"}, + {".gz", "/bin/gzip -c -- %s", "/bin/gzip -c -d -- %s"}, + {".Z", "/bin/compress -c -- %s", "/bin/uncompress -c -- %s"}, {NULL, NULL} }; struct cmds *p; @@ -1211,7 +1199,7 @@ dataconn(const char *name, off_t size, const char *mode) *sizebuf = '\0'; if (pdata >= 0) { struct sockaddr_storage from_ss; - struct sockaddr *from = (struct sockaddr *)&from; + struct sockaddr *from = (struct sockaddr *)&from_ss; int s; int fromlen = sizeof(from_ss); @@ -1501,7 +1489,7 @@ statfilecmd(char *filename) int c; char line[LINE_MAX]; - snprintf(line, sizeof(line), "/bin/ls -la %s", filename); + snprintf(line, sizeof(line), "/bin/ls -la -- %s", filename); fin = ftpd_popen(line, "r", 1, 0); lreply(211, "status of %s:", filename); while ((c = getc(fin)) != EOF) { @@ -2093,9 +2081,9 @@ list_file(char *file) pdata = -1; } else { #ifdef HAVE_LS_A - const char *cmd = "/bin/ls -lA %s"; + const char *cmd = "/bin/ls -lA -- %s"; #else - const char *cmd = "/bin/ls -la %s"; + const char *cmd = "/bin/ls -la -- %s"; #endif retrieve(cmd, file); } @@ -2146,8 +2134,8 @@ send_file_list(char *whichf) */ if (dirname[0] == '-' && *dirlist == NULL && transflag == 0) { - retrieve("/bin/ls %s", dirname); - goto out; + list_file(dirname); + goto out; } perror_reply(550, whichf); if (dout != NULL) { @@ -2241,7 +2229,7 @@ find(char *pattern) FILE *f; snprintf(line, sizeof(line), - "/bin/locate -d %s %s", + "/bin/locate -d %s -- %s", ftp_rooted("/etc/locatedb"), pattern); f = ftpd_popen(line, "r", 1, 1); diff --git a/kerberosIV/src/appl/kauth/kauthd.c b/kerberosIV/src/appl/kauth/kauthd.c index 601650a07e2..feb66f6c8c7 100644 --- a/kerberosIV/src/appl/kauth/kauthd.c +++ b/kerberosIV/src/appl/kauth/kauthd.c @@ -33,7 +33,7 @@ #include "kauth.h" -RCSID("$KTH: kauthd.c,v 1.25 1999/12/02 16:58:31 joda Exp $"); +RCSID("$KTH: kauthd.c,v 1.25.2.1 2000/06/28 19:07:58 assar Exp $"); krb_principal princ; static char locuser[SNAME_SZ]; diff --git a/kerberosIV/src/appl/sample/sample_server.c b/kerberosIV/src/appl/sample/sample_server.c index 6debf48a4fd..b18c9f0cb46 100644 --- a/kerberosIV/src/appl/sample/sample_server.c +++ b/kerberosIV/src/appl/sample/sample_server.c @@ -18,7 +18,7 @@ #include "sample.h" -RCSID("$KTH: sample_server.c,v 1.14 1999/11/13 06:28:49 assar Exp $"); +RCSID("$KTH: sample_server.c,v 1.14.2.1 2000/06/28 19:08:00 assar Exp $"); static void usage (void) |