summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Insulander <hin@cvs.openbsd.org>2002-06-07 03:10:18 +0000
committerHans Insulander <hin@cvs.openbsd.org>2002-06-07 03:10:18 +0000
commit834123059e39a4ea5c7badf15c1929c723043c91 (patch)
treeab6e1d24c39090accbf44ae859193e89660fa532
parent385660c90c407f6f834c7c1b0c07deac74beeb9c (diff)
set_progname/get_progname cleanup
-rw-r--r--kerberosIV/src/admin/ext_srvtab.c1
-rw-r--r--kerberosIV/src/admin/kdb_destroy.c2
-rw-r--r--kerberosIV/src/admin/kdb_edit.c2
-rw-r--r--kerberosIV/src/admin/kdb_init.c2
-rw-r--r--kerberosIV/src/admin/kdb_util.c22
-rw-r--r--kerberosIV/src/admin/kstash.c1
-rw-r--r--kerberosIV/src/appl/afsutil/aklog.c36
-rw-r--r--kerberosIV/src/appl/afsutil/kstring2key.c2
-rw-r--r--kerberosIV/src/appl/bsd/login.c2
-rw-r--r--kerberosIV/src/appl/bsd/rcp.c2
-rw-r--r--kerberosIV/src/appl/bsd/rlogin.c2
-rw-r--r--kerberosIV/src/appl/bsd/rlogind.c2
-rw-r--r--kerberosIV/src/appl/bsd/rsh.c18
-rw-r--r--kerberosIV/src/appl/bsd/rshd.c2
-rw-r--r--kerberosIV/src/appl/bsd/su.c2
-rw-r--r--kerberosIV/src/appl/ftp/ftp/main.c8
-rw-r--r--kerberosIV/src/appl/ftp/ftpd/ftpd.c2
-rw-r--r--kerberosIV/src/appl/kauth/kauth.c2
-rw-r--r--kerberosIV/src/appl/kip/kip.c126
-rw-r--r--kerberosIV/src/appl/kip/kipd.c128
-rw-r--r--kerberosIV/src/appl/kx/kx.c2
-rw-r--r--kerberosIV/src/appl/kx/kxd.c1
-rw-r--r--kerberosIV/src/appl/otp/otp.c1
-rw-r--r--kerberosIV/src/appl/otp/otpprint.c1
-rw-r--r--kerberosIV/src/appl/popper/pop_debug.c2
-rw-r--r--kerberosIV/src/appl/popper/pop_init.c14
-rw-r--r--kerberosIV/src/appl/push/push.c2
-rw-r--r--kerberosIV/src/appl/sample/sample_client.c1
-rw-r--r--kerberosIV/src/appl/sample/sample_server.c2
-rw-r--r--kerberosIV/src/appl/sample/simple_client.c2
-rw-r--r--kerberosIV/src/appl/sample/simple_server.c1
-rw-r--r--kerberosIV/src/appl/xnlock/xnlock.c2
-rw-r--r--kerberosIV/src/kadmin/admin_server.c2
-rw-r--r--kerberosIV/src/kadmin/kadmin.c2
-rw-r--r--kerberosIV/src/kadmin/kpasswd.c2
-rw-r--r--kerberosIV/src/kadmin/ksrvutil.c2
-rw-r--r--kerberosIV/src/kuser/kdestroy.c1
-rw-r--r--kerberosIV/src/kuser/kinit.c2
-rw-r--r--kerberosIV/src/kuser/klist.c2
-rw-r--r--kerberosIV/src/lib/auth/sia/sia.c12
-rw-r--r--kerberosIV/src/lib/com_err/compile_et.c1
-rw-r--r--kerberosIV/src/lib/sl/make_cmds.c1
-rw-r--r--kerberosIV/src/server/kerberos.c2
-rw-r--r--kerberosIV/src/slave/kprop.c2
44 files changed, 274 insertions, 152 deletions
diff --git a/kerberosIV/src/admin/ext_srvtab.c b/kerberosIV/src/admin/ext_srvtab.c
index 6c078f77f0a..2e510fff283 100644
--- a/kerberosIV/src/admin/ext_srvtab.c
+++ b/kerberosIV/src/admin/ext_srvtab.c
@@ -55,7 +55,6 @@ main(int argc, char **argv)
int prompt = KDB_GET_PROMPT;
int n, i;
- set_progname (argv[0]);
memset(realm, 0, sizeof(realm));
#ifdef HAVE_ATEXIT
diff --git a/kerberosIV/src/admin/kdb_destroy.c b/kerberosIV/src/admin/kdb_destroy.c
index 42ad20b653c..095716345f2 100644
--- a/kerberosIV/src/admin/kdb_destroy.c
+++ b/kerberosIV/src/admin/kdb_destroy.c
@@ -21,8 +21,6 @@ main(int argc, char **argv)
char *file1, *file2; /* database file names */
#endif
- set_progname (argv[0]);
-
#ifdef HAVE_NEW_DB
asprintf(&file, "%s.db", DBM_FILE);
if (file == NULL)
diff --git a/kerberosIV/src/admin/kdb_edit.c b/kerberosIV/src/admin/kdb_edit.c
index a477058c0d2..a777fb03704 100644
--- a/kerberosIV/src/admin/kdb_edit.c
+++ b/kerberosIV/src/admin/kdb_edit.c
@@ -341,8 +341,6 @@ main(int argc, char **argv)
long n;
- set_progname (argv[0]);
-
while (--argc > 0 && (*++argv)[0] == '-')
for (i = 1; argv[0][i] != '\0'; i++) {
switch (argv[0][i]) {
diff --git a/kerberosIV/src/admin/kdb_init.c b/kerberosIV/src/admin/kdb_init.c
index ebd441aff10..47bcdafc420 100644
--- a/kerberosIV/src/admin/kdb_init.c
+++ b/kerberosIV/src/admin/kdb_init.c
@@ -90,8 +90,6 @@ main(int argc, char **argv)
int code;
char *database;
- set_progname (argv[0]);
-
if (argc > 3) {
fprintf(stderr, "Usage: %s [realm-name] [database-name]\n", argv[0]);
return 1;
diff --git a/kerberosIV/src/admin/kdb_util.c b/kerberosIV/src/admin/kdb_util.c
index 1d0459d95e7..6efb5b2a04a 100644
--- a/kerberosIV/src/admin/kdb_util.c
+++ b/kerberosIV/src/admin/kdb_util.c
@@ -15,7 +15,7 @@
#include "adm_locl.h"
-RCSID("$KTH: kdb_util.c,v 1.42 1999/09/16 20:37:21 assar Exp $");
+RCSID("$KTH: kdb_util.c,v 1.42.2.1 2000/10/10 12:59:16 assar Exp $");
static des_cblock master_key, new_master_key;
static des_key_schedule master_key_schedule, new_master_key_schedule;
@@ -424,8 +424,6 @@ main(int argc, char **argv)
char *file_name;
char *db_name;
- set_progname (argv[0]);
-
if (argc != 3 && argc != 4) {
fprintf(stderr, "Usage: %s operation file [database name].\n",
argv[0]);
@@ -489,15 +487,19 @@ main(int argc, char **argv)
switch (op) {
case OP_DUMP:
- if ((dump_db (db_name, file, (void (*)(Principal *)) 0) == EOF) ||
- (fclose(file) == EOF))
- err (1, "%s", file_name);
+ if ((dump_db(db_name, file, (void (*)(Principal *)) 0) == EOF)
+ || (fflush(file) != 0)
+ || (fsync(fileno(file)) != 0)
+ || (fclose(file) == EOF))
+ err(1, "%s", file_name);
break;
case OP_SLAVE_DUMP:
- if ((dump_db (db_name, file, (void (*)(Principal *)) 0) == EOF) ||
- (fclose(file) == EOF))
- err (1, "%s", file_name);
- update_ok_file (file_name);
+ if ((dump_db(db_name, file, (void (*)(Principal *)) 0) == EOF)
+ || (fflush(file) != 0)
+ || (fsync(fileno(file)) != 0)
+ || (fclose(file) == EOF))
+ err(1, "%s", file_name);
+ update_ok_file(file_name);
break;
case OP_LOAD:
load_db (db_name, file);
diff --git a/kerberosIV/src/admin/kstash.c b/kerberosIV/src/admin/kstash.c
index d0ade032e08..ac1e6ad916e 100644
--- a/kerberosIV/src/admin/kstash.c
+++ b/kerberosIV/src/admin/kstash.c
@@ -29,7 +29,6 @@ main(int argc, char **argv)
{
long n;
int ret = 0;
- set_progname (argv[0]);
if ((n = kerb_init()))
errx(1, "Kerberos db and cache init failed = %ld\n", n);
diff --git a/kerberosIV/src/appl/afsutil/aklog.c b/kerberosIV/src/appl/afsutil/aklog.c
index 4c006ce1d77..4d5a0d1adba 100644
--- a/kerberosIV/src/appl/afsutil/aklog.c
+++ b/kerberosIV/src/appl/afsutil/aklog.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995 - 1999 Kungliga Tekniska Högskolan
+ * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -66,7 +66,7 @@
#include <roken.h>
-RCSID("$KTH: aklog.c,v 1.24 1999/12/02 16:58:28 joda Exp $");
+RCSID("$KTH: aklog.c,v 1.24.2.1 2000/06/23 02:31:15 assar Exp $");
static int debug = 0;
@@ -89,15 +89,15 @@ DEBUG(const char *fmt, ...)
}
static char *
-expand_cell_name(char *cell)
+expand_1 (const char *cell, const char *filename)
{
FILE *f;
static char buf[128];
char *p;
- f = fopen(_PATH_CELLSERVDB, "r");
+ f = fopen(filename, "r");
if(f == NULL)
- return cell;
+ return NULL;
while(fgets(buf, sizeof(buf), f) != NULL) {
if(buf[0] == '>') {
for(p=buf; *p && !isspace(*p) && *p != '#'; p++)
@@ -111,11 +111,25 @@ expand_cell_name(char *cell)
buf[0] = 0;
}
fclose(f);
+ return NULL;
+}
+
+static const char *
+expand_cell_name(const char *cell)
+{
+ char *ret;
+
+ ret = expand_1(cell, _PATH_CELLSERVDB);
+ if (ret != NULL)
+ return ret;
+ ret = expand_1(cell, _PATH_ARLA_CELLSERVDB);
+ if (ret != NULL)
+ return ret;
return cell;
}
static int
-createuser (char *cell)
+createuser (const char *cell)
{
char cellbuf[64];
char name[ANAME_SZ];
@@ -129,9 +143,11 @@ createuser (char *cell)
f = fopen (_PATH_THISCELL, "r");
if (f == NULL)
- err (1, "open(%s)", _PATH_THISCELL);
+ f = fopen (_PATH_ARLA_THISCELL, "r");
+ if (f == NULL)
+ err (1, "open(%s, %s)", _PATH_THISCELL, _PATH_ARLA_THISCELL);
if (fgets (cellbuf, sizeof(cellbuf), f) == NULL)
- err (1, "read cellname from %s", _PATH_THISCELL);
+ err (1, "read cellname from %s %s", _PATH_THISCELL, _PATH_ARLA_THISCELL);
fclose (f);
len = strlen(cellbuf);
if (cellbuf[len-1] == '\n')
@@ -156,12 +172,10 @@ main(int argc, char **argv)
int i;
int do_aklog = -1;
int do_createuser = -1;
- char *cell = NULL;
+ const char *cell = NULL;
char *realm = NULL;
char cellbuf[64];
- set_progname (argv[0]);
-
if(!k_hasafs())
exit(1);
diff --git a/kerberosIV/src/appl/afsutil/kstring2key.c b/kerberosIV/src/appl/afsutil/kstring2key.c
index 8283b352920..539755b2e7b 100644
--- a/kerberosIV/src/appl/afsutil/kstring2key.c
+++ b/kerberosIV/src/appl/afsutil/kstring2key.c
@@ -81,8 +81,6 @@ main(int argc, char **argv)
char buf[1024];
char *cellname = 0, *salt = 0;
- set_progname (argv[0]);
-
if (argc >= 3 && argv[1][0] == '-' && argv[1][1] == 'c')
{
cellname = argv[2];
diff --git a/kerberosIV/src/appl/bsd/login.c b/kerberosIV/src/appl/bsd/login.c
index 1c3e801f6d5..0268568fc11 100644
--- a/kerberosIV/src/appl/bsd/login.c
+++ b/kerberosIV/src/appl/bsd/login.c
@@ -189,8 +189,6 @@ main(int argc, char **argv)
int mask = 022; /* Default umask (set below) */
int maxtrys = 5; /* Default number of allowed failed logins */
- set_progname(argv[0]);
-
openlog("login", LOG_ODELAY, LOG_AUTH);
/* Read defaults file and set the login timeout period. */
diff --git a/kerberosIV/src/appl/bsd/rcp.c b/kerberosIV/src/appl/bsd/rcp.c
index 27c8bfb8be8..173aa90ce66 100644
--- a/kerberosIV/src/appl/bsd/rcp.c
+++ b/kerberosIV/src/appl/bsd/rcp.c
@@ -923,8 +923,6 @@ main(int argc, char **argv)
char *targ;
int i;
- set_progname(argv[0]);
-
/*
* Prepare for execing ourselves.
*/
diff --git a/kerberosIV/src/appl/bsd/rlogin.c b/kerberosIV/src/appl/bsd/rlogin.c
index e9e29fa045d..1efb9e64f53 100644
--- a/kerberosIV/src/appl/bsd/rlogin.c
+++ b/kerberosIV/src/appl/bsd/rlogin.c
@@ -549,8 +549,6 @@ main(int argc, char **argv)
one = 1;
host = user = NULL;
- set_progname(argv[0]);
-
/* handle "rlogin host flags" */
if (argc > 2 && argv[1][0] != '-') {
host = argv[1];
diff --git a/kerberosIV/src/appl/bsd/rlogind.c b/kerberosIV/src/appl/bsd/rlogind.c
index e29410fe4cd..3a06c6954bc 100644
--- a/kerberosIV/src/appl/bsd/rlogind.c
+++ b/kerberosIV/src/appl/bsd/rlogind.c
@@ -314,8 +314,6 @@ main(int argc, char **argv)
int interactive = 0;
int portnum = 0;
- set_progname(argv[0]);
-
openlog("rlogind", LOG_PID | LOG_CONS, LOG_AUTH);
opterr = 0;
diff --git a/kerberosIV/src/appl/bsd/rsh.c b/kerberosIV/src/appl/bsd/rsh.c
index 87fe860064e..cd9a0779060 100644
--- a/kerberosIV/src/appl/bsd/rsh.c
+++ b/kerberosIV/src/appl/bsd/rsh.c
@@ -33,7 +33,7 @@
#include "bsd_locl.h"
-RCSID("$KTH: rsh.c,v 1.43 1999/11/13 06:13:34 assar Exp $");
+RCSID("$KTH: rsh.c,v 1.43.2.2 2000/10/10 12:53:50 assar Exp $");
CREDENTIALS cred;
Key_schedule schedule;
@@ -107,7 +107,10 @@ talk(int nflag, sigset_t omask, int pid, int rem)
goto done;
bp = buf;
- rewrite: FD_ZERO(&rembits);
+ rewrite:
+ FD_ZERO(&rembits);
+ if (rem >= FD_SETSIZE)
+ errx(1, "fd too large");
FD_SET(rem, &rembits);
if (select(rem + 1, 0, &rembits, 0, 0) < 0) {
if (errno != EINTR)
@@ -140,6 +143,8 @@ talk(int nflag, sigset_t omask, int pid, int rem)
if (sigprocmask(SIG_SETMASK, &omask, 0) != 0)
warn("sigprocmask");
FD_ZERO(&readfrom);
+ if (rem >= FD_SETSIZE || rfd2 >= FD_SETSIZE)
+ errx(1, "fd too large");
FD_SET(rem, &readfrom);
FD_SET(rfd2, &readfrom);
do {
@@ -196,8 +201,6 @@ main(int argc, char **argv)
host = user = NULL;
pid = 1;
- set_progname(argv[0]);
-
/* handle "rsh host flags" */
if (argc > 2 && argv[1][0] != '-') {
host = argv[1];
@@ -253,7 +256,7 @@ main(int argc, char **argv)
/* if no further arguments, must have been called as rlogin. */
if (!argv[optind]) {
*argv = "rlogin";
- setuid(getuid());
+ paranoid_setuid (getuid ());
execv(_PATH_RLOGIN, argv);
err(1, "can't exec %s", _PATH_RLOGIN);
}
@@ -282,7 +285,7 @@ main(int argc, char **argv)
sv_port = get_shell_port(use_kerberos, doencrypt);
if (use_kerberos) {
- setuid(getuid());
+ paranoid_setuid(getuid());
rem = KSUCCESS;
errno = 0;
if (dest_realm == NULL)
@@ -342,7 +345,7 @@ main(int argc, char **argv)
}
#endif
- setuid(uid);
+ paranoid_setuid(uid);
{
sigset_t sigmsk;
sigemptyset(&sigmsk);
@@ -358,6 +361,7 @@ main(int argc, char **argv)
signal(SIGQUIT, sendsig);
if (signal(SIGTERM, SIG_IGN) != SIG_IGN)
signal(SIGTERM, sendsig);
+ signal(SIGPIPE, SIG_IGN);
if (!nfork) {
pid = fork();
diff --git a/kerberosIV/src/appl/bsd/rshd.c b/kerberosIV/src/appl/bsd/rshd.c
index 955a71c2832..38c24b9741d 100644
--- a/kerberosIV/src/appl/bsd/rshd.c
+++ b/kerberosIV/src/appl/bsd/rshd.c
@@ -77,8 +77,6 @@ main(int argc, char *argv[])
struct sockaddr_in from;
int portnum = 0;
- set_progname(argv[0]);
-
openlog("rshd", LOG_PID | LOG_ODELAY, LOG_DAEMON);
opterr = 0;
diff --git a/kerberosIV/src/appl/bsd/su.c b/kerberosIV/src/appl/bsd/su.c
index f1d28d58831..36b6bb198b2 100644
--- a/kerberosIV/src/appl/bsd/su.c
+++ b/kerberosIV/src/appl/bsd/su.c
@@ -65,8 +65,6 @@ main (int argc, char **argv)
char shellbuf[MaxPathLen], avshellbuf[MaxPathLen];
char *realm = NULL;
- set_progname (argv[0]);
-
if (getuid() == 0)
use_kerberos = 0;
diff --git a/kerberosIV/src/appl/ftp/ftp/main.c b/kerberosIV/src/appl/ftp/ftp/main.c
index 53cdea0016c..3e5924a3784 100644
--- a/kerberosIV/src/appl/ftp/ftp/main.c
+++ b/kerberosIV/src/appl/ftp/ftp/main.c
@@ -36,7 +36,7 @@
*/
#include "ftp_locl.h"
-RCSID("$KTH: main.c,v 1.27 1999/11/13 06:18:02 assar Exp $");
+RCSID("$KTH: main.c,v 1.27.2.1 2000/10/10 13:01:50 assar Exp $");
int
main(int argc, char **argv)
@@ -46,8 +46,6 @@ main(int argc, char **argv)
char homedir[MaxPathLen];
struct servent *sp;
- set_progname(argv[0]);
-
sp = getservbyname("ftp", "tcp");
if (sp == 0)
errx(1, "ftp/tcp: unknown service");
@@ -244,8 +242,10 @@ cmdscanner(int top)
if (fromatty) {
char *p;
p = readline("ftp> ");
- if(p == NULL)
+ if(p == NULL) {
+ printf("\n");
quit(0, 0);
+ }
strlcpy(line, p, sizeof(line));
add_history(p);
free(p);
diff --git a/kerberosIV/src/appl/ftp/ftpd/ftpd.c b/kerberosIV/src/appl/ftp/ftpd/ftpd.c
index 631336ee89f..8bcabcafb80 100644
--- a/kerberosIV/src/appl/ftp/ftpd/ftpd.c
+++ b/kerberosIV/src/appl/ftp/ftpd/ftpd.c
@@ -260,8 +260,6 @@ main(int argc, char **argv)
int optind = 0;
- set_progname (argv[0]);
-
#ifdef KRB4
/* detach from any tickets and tokens */
{
diff --git a/kerberosIV/src/appl/kauth/kauth.c b/kerberosIV/src/appl/kauth/kauth.c
index 47b05f0c19e..362af2c6803 100644
--- a/kerberosIV/src/appl/kauth/kauth.c
+++ b/kerberosIV/src/appl/kauth/kauth.c
@@ -207,8 +207,6 @@ main(int argc, char **argv)
int nhost;
char tf[MaxPathLen];
- set_progname (argv[0]);
-
if ((file = getenv("KRBTKFILE")) == 0)
file = TKT_FILE;
diff --git a/kerberosIV/src/appl/kip/kip.c b/kerberosIV/src/appl/kip/kip.c
index 9ed601d32b1..12a66006d02 100644
--- a/kerberosIV/src/appl/kip/kip.c
+++ b/kerberosIV/src/appl/kip/kip.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Högskolan
+ * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -33,14 +33,31 @@
#include "kip.h"
-RCSID("$KTH: kip.c,v 1.18 1999/12/02 16:58:31 joda Exp $");
+RCSID("$KTH: kip.c,v 1.18.2.1 2000/06/23 02:55:01 assar Exp $");
-static void
-usage(void)
+static char *cmd_str = NULL;
+static char *arg_str = NULL;
+static char *port_str = NULL;
+static int version_flag = 0;
+static int help_flag = 0;
+
+struct getargs args[] = {
+ { "port", 'p', arg_string, &port_str, "Use this port",
+ "port" },
+ { "cmd", 'c', arg_string, &cmd_str,
+ "command to run when starting", "cmd"},
+ { "arg", 'a', arg_string, &arg_str,
+ "argument to above command", "arg"},
+ { "version", 0, arg_flag, &version_flag },
+ { "help", 0, arg_flag, &help_flag }
+};
+
+
+static RETSIGTYPE
+disconnecthandler (int sig)
{
- fprintf (stderr, "Usage: %s host\n",
- __progname);
- exit (1);
+ disconnect = 1;
+ SIGRETURN(0);
}
/*
@@ -48,7 +65,8 @@ usage(void)
*/
static int
-connect_host (char *host, des_cblock *key, des_key_schedule schedule)
+connect_host (char *host, int port,
+ des_cblock *key, des_key_schedule schedule)
{
CREDENTIALS cred;
KTEXT_ST text;
@@ -70,7 +88,7 @@ connect_host (char *host, des_cblock *key, des_key_schedule schedule)
memset (&thataddr, 0, sizeof(thataddr));
thataddr.sin_family = AF_INET;
- thataddr.sin_port = k_getportbyname ("kip", "tcp", htons(KIPPORT));
+ thataddr.sin_port = port;
for(p = hostent->h_addr_list; *p; ++p) {
memcpy (&thataddr.sin_addr, *p, sizeof(thataddr.sin_addr));
@@ -139,19 +157,50 @@ connect_host (char *host, des_cblock *key, des_key_schedule schedule)
*/
static int
-doit (char *host)
+doit (char *host, int port)
{
+ char tun_if_name[64];
des_key_schedule schedule;
des_cblock iv;
- int other, this;
+ int other, this, ret;
- other = connect_host (host, &iv, schedule);
+ other = connect_host (host, port, &iv, schedule);
if (other < 0)
return 1;
- this = tunnel_open ();
+ this = tunnel_open (tun_if_name, sizeof(tun_if_name));
if (this < 0)
return 1;
- return copy_packets (this, other, TUNMTU, &iv, schedule);
+
+ if (cmd_str) {
+ char buf[1024];
+ ret = kip_exec (cmd_str, buf, sizeof(buf),
+ "kip-control", "up", tun_if_name, host, arg_str,
+ NULL);
+ if (ret)
+ errx (1, "%s (up) failed: %s", cmd_str, buf);
+ }
+
+ ret = copy_packets (this, other, TUNMTU, &iv, schedule);
+
+ if (cmd_str) {
+ char buf[1024];
+ ret = kip_exec (cmd_str, buf, sizeof(buf),
+ "kip-control", "down", tun_if_name, host, arg_str,
+ NULL);
+ if (ret)
+ errx (1, "%s (down) failed: %s", cmd_str, buf);
+ }
+ return 0;
+}
+
+static void
+usage(int ret)
+{
+ arg_printusage (args,
+ sizeof(args) / sizeof(args[0]),
+ NULL,
+ "hostname");
+ exit (ret);
}
/*
@@ -162,9 +211,50 @@ doit (char *host)
int
main(int argc, char **argv)
{
- set_progname (argv[0]);
+ int port;
+ int optind = 0;
+ char *hostname;
+
+ if (getarg (args, sizeof(args) / sizeof(args[0]), argc, argv,
+ &optind))
+ usage (1);
+
+ if (help_flag)
+ usage (0);
+
+ if (version_flag) {
+ print_version (NULL);
+ return 0;
+ }
+
+ argv += optind;
+ argc -= optind;
+
+ if (argc != 1)
+ usage (1);
+
+ hostname = argv[0];
+
+ if(port_str) {
+ struct servent *s = roken_getservbyname (port_str, "tcp");
+
+ if (s)
+ port = s->s_port;
+ else {
+ char *ptr;
+
+ port = strtol (port_str, &ptr, 10);
+ if (port == 0 && ptr == port_str)
+ errx (1, "bad port `%s'", port_str);
+ port = htons(port);
+ }
+ } else {
+ port = k_getportbyname ("kip", "tcp", htons(KIPPORT));
+ }
+
+ signal (SIGCHLD, childhandler);
+ signal (SIGHUP, disconnecthandler);
+ signal (SIGTERM, disconnecthandler);
- if (argc != 2)
- usage ();
- return doit (argv[1]);
+ return doit (hostname, port);
}
diff --git a/kerberosIV/src/appl/kip/kipd.c b/kerberosIV/src/appl/kip/kipd.c
index c2bef4ec5bc..f53b3b147fb 100644
--- a/kerberosIV/src/appl/kip/kipd.c
+++ b/kerberosIV/src/appl/kip/kipd.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska Högskolan
+ * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -33,22 +33,11 @@
#include "kip.h"
-RCSID("$KTH: kipd.c,v 1.16 1999/12/02 16:58:31 joda Exp $");
-
-static int
-fatal (int fd, char *s)
-{
- u_char err = 1;
-
- write (fd, &err, sizeof(err));
- write (fd, s, strlen(s)+1);
- syslog(LOG_ERR, s);
- return err;
-}
+RCSID("$KTH: kipd.c,v 1.16.2.3 2000/10/18 20:46:45 assar Exp $");
static int
recv_conn (int sock, des_cblock *key, des_key_schedule schedule,
- struct sockaddr_in *retaddr)
+ struct sockaddr_in *retaddr, char *user, size_t len)
{
int status;
KTEXT_ST ticket;
@@ -80,13 +69,21 @@ recv_conn (int sock, des_cblock *key, des_key_schedule schedule,
return 1;
}
passwd = k_getpwnam ("root");
- if (passwd == NULL)
- return fatal (sock, "Cannot find root");
- if (kuserok(&auth, "root") != 0)
- return fatal (sock, "Permission denied");
+ if (passwd == NULL) {
+ fatal (sock, "Cannot find root", schedule, &auth.session);
+ return 1;
+ }
+ if (kuserok(&auth, "root") != 0) {
+ fatal (sock, "Permission denied", schedule, &auth.session);
+ return 1;
+ }
if (write (sock, &ok, sizeof(ok)) != sizeof(ok))
return 1;
+ snprintf (user, len, "%s%s%s@%s", auth.pname,
+ auth.pinst[0] != '\0' ? "." : "",
+ auth.pinst, auth.prealm);
+
memcpy(key, &auth.session, sizeof(des_cblock));
*retaddr = thataddr;
return 0;
@@ -95,17 +92,64 @@ recv_conn (int sock, des_cblock *key, des_key_schedule schedule,
static int
doit(int sock)
{
+ char msg[1024];
+ char cmd[MAXPATHLEN];
+ char tun_if_name[64];
+ char user[MAX_K_NAME_SZ];
struct sockaddr_in thataddr;
des_key_schedule schedule;
des_cblock key;
- int this;
+ int this, ret, ret2;
+
+ isserver = 1;
- if (recv_conn (sock, &key, schedule, &thataddr))
+ if (recv_conn (sock, &key, schedule, &thataddr, user, sizeof(user)))
return 1;
- this = tunnel_open ();
+ this = tunnel_open (tun_if_name, sizeof(tun_if_name));
if (this < 0)
- fatal (sock, "Cannot open " _PATH_DEV TUNDEV);
- return copy_packets (this, sock, TUNMTU, &key, schedule);
+ fatal (sock, "Cannot open " _PATH_DEV TUNDEV, schedule, &key);
+
+ strlcpy(cmd, LIBEXECDIR "/kipd-control", sizeof(cmd));
+
+ ret = kip_exec (cmd, msg, sizeof(msg), "kipd-control",
+ "up", tun_if_name, inet_ntoa(thataddr.sin_addr), user,
+ NULL);
+ if (ret) {
+ fatal (sock, msg, schedule, &key);
+ return -1;
+ }
+
+ ret = copy_packets (this, sock, TUNMTU, &key, schedule);
+
+ ret2 = kip_exec (cmd, msg, sizeof(msg), "kipd-control",
+ "down", tun_if_name, user, NULL);
+ if (ret2)
+ syslog(LOG_ERR, "%s", msg);
+ return ret;
+}
+
+static char *port_str = NULL;
+static int inetd_flag = 1;
+static int version_flag = 0;
+static int help_flag = 0;
+
+struct getargs args[] = {
+ { "inetd", 'i', arg_negative_flag, &inetd_flag,
+ "Not started from inetd" },
+ { "port", 'p', arg_string, &port_str, "Use this port",
+ "port" },
+ { "version", 0, arg_flag, &version_flag },
+ { "help", 0, arg_flag, &help_flag }
+};
+
+static void
+usage(int ret)
+{
+ arg_printusage (args,
+ sizeof(args) / sizeof(args[0]),
+ NULL,
+ "");
+ exit (ret);
}
/*
@@ -115,9 +159,43 @@ doit(int sock)
int
main (int argc, char **argv)
{
- set_progname (argv[0]);
+ int port;
+ int optind = 0;
roken_openlog(__progname, LOG_PID|LOG_CONS, LOG_DAEMON);
+
+ if (getarg (args, sizeof(args) / sizeof(args[0]), argc, argv,
+ &optind))
+ usage (1);
+
+ if (help_flag)
+ usage (0);
+
+ if (version_flag) {
+ print_version (NULL);
+ return 0;
+ }
+
+ if(port_str) {
+ struct servent *s = roken_getservbyname (port_str, "tcp");
+
+ if (s)
+ port = s->s_port;
+ else {
+ char *ptr;
+
+ port = strtol (port_str, &ptr, 10);
+ if (port == 0 && ptr == port_str)
+ errx (1, "bad port `%s'", port_str);
+ port = htons(port);
+ }
+ } else {
+ port = k_getportbyname ("kip", "tcp", htons(KIPPORT));
+ }
+
+ if (!inetd_flag)
+ mini_inetd (port);
+
signal (SIGCHLD, childhandler);
- return doit(0);
+ return doit(STDIN_FILENO);
}
diff --git a/kerberosIV/src/appl/kx/kx.c b/kerberosIV/src/appl/kx/kx.c
index d89d617ccd1..1715d1bc0a2 100644
--- a/kerberosIV/src/appl/kx/kx.c
+++ b/kerberosIV/src/appl/kx/kx.c
@@ -685,8 +685,6 @@ main(int argc, char **argv)
int ret = 1;
char *host = NULL;
- set_progname (argv[0]);
-
if (getarg (args, sizeof(args) / sizeof(args[0]), argc, argv,
&optind))
usage (1);
diff --git a/kerberosIV/src/appl/kx/kxd.c b/kerberosIV/src/appl/kx/kxd.c
index 924d4d305a8..73106d2e20d 100644
--- a/kerberosIV/src/appl/kx/kxd.c
+++ b/kerberosIV/src/appl/kx/kxd.c
@@ -693,7 +693,6 @@ main (int argc, char **argv)
int port;
int optind = 0;
- set_progname (argv[0]);
roken_openlog ("kxd", LOG_ODELAY | LOG_PID, LOG_DAEMON);
if (getarg (args, sizeof(args) / sizeof(args[0]), argc, argv,
diff --git a/kerberosIV/src/appl/otp/otp.c b/kerberosIV/src/appl/otp/otp.c
index 4d5b78ee484..f539aaf82a4 100644
--- a/kerberosIV/src/appl/otp/otp.c
+++ b/kerberosIV/src/appl/otp/otp.c
@@ -293,7 +293,6 @@ main (int argc, char **argv)
OtpAlgorithm *alg = otp_find_alg (OTP_ALG_DEFAULT);
int optind = 0;
- set_progname (argv[0]);
if(getarg(args, num_args, argc, argv, &optind))
usage(1);
if(help_flag)
diff --git a/kerberosIV/src/appl/otp/otpprint.c b/kerberosIV/src/appl/otp/otpprint.c
index e5108b86c7f..2099aa167c2 100644
--- a/kerberosIV/src/appl/otp/otpprint.c
+++ b/kerberosIV/src/appl/otp/otpprint.c
@@ -101,7 +101,6 @@ main (int argc, char **argv)
void (*fn)(OtpKey, char *, size_t);
OtpAlgorithm *alg = otp_find_alg (OTP_ALG_DEFAULT);
- set_progname (argv[0]);
if(getarg(args, num_args, argc, argv, &optind))
usage(1);
if(help_flag)
diff --git a/kerberosIV/src/appl/popper/pop_debug.c b/kerberosIV/src/appl/popper/pop_debug.c
index b5aff9aec38..912854b0a09 100644
--- a/kerberosIV/src/appl/popper/pop_debug.c
+++ b/kerberosIV/src/appl/popper/pop_debug.c
@@ -225,8 +225,6 @@ main(int argc, char **argv)
int ret = 1;
int optind = 0;
- set_progname(argv[0]);
-
if (getarg (args, sizeof(args) / sizeof(args[0]), argc, argv,
&optind))
usage (1);
diff --git a/kerberosIV/src/appl/popper/pop_init.c b/kerberosIV/src/appl/popper/pop_init.c
index a76e7e70311..ada8d958375 100644
--- a/kerberosIV/src/appl/popper/pop_init.c
+++ b/kerberosIV/src/appl/popper/pop_init.c
@@ -5,7 +5,7 @@
*/
#include <popper.h>
-RCSID("$KTH: pop_init.c,v 1.51 1999/10/16 13:12:02 joda Exp $");
+RCSID("$KTH: pop_init.c,v 1.51.2.1 2000/04/12 15:47:58 assar Exp $");
#if defined(KRB4) || defined(KRB5)
@@ -55,7 +55,7 @@ krb4_authenticate (POP *p, int s, u_char *buf, struct sockaddr *addr)
if (auth != KSUCCESS) {
pop_msg(p, POP_FAILURE, "Kerberos authentication failure: %s",
krb_get_err_text(auth));
- pop_log(p, POP_FAILURE, "%s: (%s.%s@%s) %s", p->client,
+ pop_log(p, POP_PRIORITY, "%s: (%s.%s@%s) %s", p->client,
p->kdata.pname, p->kdata.pinst, p->kdata.prealm,
krb_get_err_text(auth));
exit (1);
@@ -100,14 +100,14 @@ krb5_authenticate (POP *p, int s, u_char *buf, struct sockaddr *addr)
char *s;
ret = krb5_unparse_name(p->context, ticket->server, &s);
if(ret) {
- pop_log(p, POP_FAILURE, "krb5_unparse_name: %s",
+ pop_log(p, POP_PRIORITY, "krb5_unparse_name: %s",
krb5_get_err_text(p->context, ret));
exit(1);
}
/* does this make sense? */
- if(strncmp(s, "pop/", 4) != 0) {
- pop_log(p, POP_FAILURE,
- "Got ticket for service `%s'", s);
+ if(strncmp(server, "pop/", 4) != 0) {
+ pop_log(p, POP_PRIORITY,
+ "Got ticket for service `%s'", server);
exit(1);
} else if(p->debug)
pop_log(p, POP_DEBUG,
@@ -216,8 +216,6 @@ pop_init(POP *p,int argcount,char **argmessage)
/* Initialize the POP parameter block */
memset (p, 0, sizeof(POP));
- set_progname(argmessage[0]);
-
/* Save my name in a global variable */
p->myname = (char*)__progname;
diff --git a/kerberosIV/src/appl/push/push.c b/kerberosIV/src/appl/push/push.c
index 2df3629a0c6..303ec8bf9a0 100644
--- a/kerberosIV/src/appl/push/push.c
+++ b/kerberosIV/src/appl/push/push.c
@@ -702,8 +702,6 @@ main(int argc, char **argv)
const char *host, *user, *filename = NULL;
char *pobox = NULL;
- set_progname (argv[0]);
-
#ifdef KRB5
krb5_init_context (&context);
#endif
diff --git a/kerberosIV/src/appl/sample/sample_client.c b/kerberosIV/src/appl/sample/sample_client.c
index 541c94b3d53..3fe94eb5985 100644
--- a/kerberosIV/src/appl/sample/sample_client.c
+++ b/kerberosIV/src/appl/sample/sample_client.c
@@ -55,7 +55,6 @@ main(int argc, char **argv)
struct servent *serv;
char **h_addr_list;
- set_progname (argv[0]);
strlcpy (service, SAMPLE_SERVICE, sizeof(service));
port = 0;
diff --git a/kerberosIV/src/appl/sample/sample_server.c b/kerberosIV/src/appl/sample/sample_server.c
index b18c9f0cb46..4a35f5ef2a5 100644
--- a/kerberosIV/src/appl/sample/sample_server.c
+++ b/kerberosIV/src/appl/sample/sample_server.c
@@ -49,8 +49,6 @@ main(int argc, char **argv)
/* open a log connection */
- set_progname (argv[0]);
-
roken_openlog(__progname, LOG_ODELAY, LOG_DAEMON);
strlcpy (service, SAMPLE_SERVICE, sizeof(service));
diff --git a/kerberosIV/src/appl/sample/simple_client.c b/kerberosIV/src/appl/sample/simple_client.c
index 7ccc70073e7..498734d95ae 100644
--- a/kerberosIV/src/appl/sample/simple_client.c
+++ b/kerberosIV/src/appl/sample/simple_client.c
@@ -172,8 +172,6 @@ main(int argc, char **argv)
struct servent *serv;
int c;
- set_progname (argv[0]);
-
strlcpy (service, SAMPLE_SERVICE, sizeof(service));
while ((c = getopt(argc, argv, "s:p:")) != -1)
diff --git a/kerberosIV/src/appl/sample/simple_server.c b/kerberosIV/src/appl/sample/simple_server.c
index 3c839c23849..320363133f6 100644
--- a/kerberosIV/src/appl/sample/simple_server.c
+++ b/kerberosIV/src/appl/sample/simple_server.c
@@ -39,7 +39,6 @@ main(int argc, char **argv)
MSG_DAT msg_data;
des_key_schedule sched;
- set_progname (argv[0]);
strlcpy (service, SAMPLE_SERVICE, sizeof(service));
strlcpy (instance, "*", sizeof(instance));
*srvtab = '\0';
diff --git a/kerberosIV/src/appl/xnlock/xnlock.c b/kerberosIV/src/appl/xnlock/xnlock.c
index 31843f4ee75..011f9f91d2f 100644
--- a/kerberosIV/src/appl/xnlock/xnlock.c
+++ b/kerberosIV/src/appl/xnlock/xnlock.c
@@ -919,8 +919,6 @@ main (int argc, char **argv)
Widget override;
XGCValues gcvalues;
- set_progname (argv[0]);
-
/*
* Must be setuid root to read /etc/shadow, copy encrypted
* passwords here and then switch to sane uid.
diff --git a/kerberosIV/src/kadmin/admin_server.c b/kerberosIV/src/kadmin/admin_server.c
index 29d2b3aa536..5aeeedc8e0e 100644
--- a/kerberosIV/src/kadmin/admin_server.c
+++ b/kerberosIV/src/kadmin/admin_server.c
@@ -528,8 +528,6 @@ main(int argc, char **argv) /* admin_server main routine */
int c;
struct in_addr i_addr;
- set_progname (argv[0]);
-
umask(077); /* Create protected files */
i_addr.s_addr = INADDR_ANY;
diff --git a/kerberosIV/src/kadmin/kadmin.c b/kerberosIV/src/kadmin/kadmin.c
index 6fe636da434..74e3e9090a8 100644
--- a/kerberosIV/src/kadmin/kadmin.c
+++ b/kerberosIV/src/kadmin/kadmin.c
@@ -374,8 +374,6 @@ do_init(int argc, char **argv)
int optind = 0;
int ret;
- set_progname (argv[0]);
-
if(getarg(args, num_args, argc, argv, &optind) < 0)
usage(1);
if(help_flag)
diff --git a/kerberosIV/src/kadmin/kpasswd.c b/kerberosIV/src/kadmin/kpasswd.c
index 8d8295351ee..ed32b39e81a 100644
--- a/kerberosIV/src/kadmin/kpasswd.c
+++ b/kerberosIV/src/kadmin/kpasswd.c
@@ -48,8 +48,6 @@ main(int argc, char **argv)
int c;
char tktstring[MaxPathLen];
- set_progname (argv[0]);
-
memset (&principal, 0, sizeof(principal));
memset (&default_principal, 0, sizeof(default_principal));
diff --git a/kerberosIV/src/kadmin/ksrvutil.c b/kerberosIV/src/kadmin/ksrvutil.c
index 6a3a9e51f5e..3416e2630ff 100644
--- a/kerberosIV/src/kadmin/ksrvutil.c
+++ b/kerberosIV/src/kadmin/ksrvutil.c
@@ -315,8 +315,6 @@ main(int argc, char **argv)
memset(local_realm, 0, sizeof(local_realm));
memset(cellname, 0, sizeof(cellname));
- set_progname (argv[0]);
-
if (krb_get_default_principal(u_name, u_inst, u_realm) < 0)
errx (1, "could not get default principal");
diff --git a/kerberosIV/src/kuser/kdestroy.c b/kerberosIV/src/kuser/kdestroy.c
index f9e632ca203..45583209636 100644
--- a/kerberosIV/src/kuser/kdestroy.c
+++ b/kerberosIV/src/kuser/kdestroy.c
@@ -75,7 +75,6 @@ main(int argc, char **argv)
int optind = 0;
int ret = RET_TKFIL;
- set_progname(argv[0]);
if(getarg(args, num_args, argc, argv, &optind))
usage(1);
diff --git a/kerberosIV/src/kuser/kinit.c b/kerberosIV/src/kuser/kinit.c
index c2e4d02fcb9..c03d7170f13 100644
--- a/kerberosIV/src/kuser/kinit.c
+++ b/kerberosIV/src/kuser/kinit.c
@@ -55,8 +55,6 @@ main(int argc, char **argv)
int iflag, rflag, vflag, lflag, pflag, lifetime, k_errno;
int i;
- set_progname (argv[0]);
-
*inst = *realm = '\0';
iflag = rflag = vflag = lflag = pflag = 0;
lifetime = LIFE;
diff --git a/kerberosIV/src/kuser/klist.c b/kerberosIV/src/kuser/klist.c
index 33b5cf1adaa..1d2c057ec3b 100644
--- a/kerberosIV/src/kuser/klist.c
+++ b/kerberosIV/src/kuser/klist.c
@@ -341,8 +341,6 @@ main(int argc, char **argv)
char *tkt_file = NULL;
int eval;
- set_progname(argv[0]);
-
while (*(++argv)) {
if (!strcmp(*argv, "-v")) {
option_verbose = 1;
diff --git a/kerberosIV/src/lib/auth/sia/sia.c b/kerberosIV/src/lib/auth/sia/sia.c
index d31c1da2a47..e74524ad055 100644
--- a/kerberosIV/src/lib/auth/sia/sia.c
+++ b/kerberosIV/src/lib/auth/sia/sia.c
@@ -33,7 +33,7 @@
#include "sia_locl.h"
-RCSID("$KTH: sia.c,v 1.32 1999/10/03 15:49:36 joda Exp $");
+RCSID("$KTH: sia.c,v 1.32.2.1 1999/12/20 09:49:30 joda Exp $");
int
siad_init(void)
@@ -145,7 +145,7 @@ doauth(SIAENTITY *entity, int pkgind, char *name)
#ifdef SIA_KRB4
snprintf(s->ticket, sizeof(s->ticket),
- TKT_ROOT "%u_%u", (unsigned)pwd->pw_uid, (unsigned)getpid());
+ "%s%u_%u", TKT_ROOT, (unsigned)pwd->pw_uid, (unsigned)getpid());
krb_get_lrealm(realm, 1);
toname = name;
toinst = "";
@@ -160,8 +160,8 @@ doauth(SIAENTITY *entity, int pkgind, char *name)
SIA_DEBUG(("DEBUG", "failed to getpwuid(%u)", ouid));
return SIADFAIL;
}
- snprintf(s->ticket, sizeof(s->ticket), TKT_ROOT "_%s_to_%s_%d",
- fpwd->pw_name, pwd->pw_name, getpid());
+ snprintf(s->ticket, sizeof(s->ticket), "%s_%s_to_%s_%d",
+ TKT_ROOT, fpwd->pw_name, pwd->pw_name, getpid());
if(strcmp(pwd->pw_name, "root") == 0){
toname = fpwd->pw_name;
toinst = pwd->pw_name;
@@ -454,7 +454,7 @@ init_change(sia_collect_func_t *collect, krb_principal *princ)
if(ret != SIACOLSUCCESS)
return SIADFAIL;
snprintf(tktstring, sizeof(tktstring),
- TKT_ROOT "_cpw_%u", (unsigned)getpid());
+ "%s_cpw_%u", TKT_ROOT, (unsigned)getpid());
krb_set_tkt_string(tktstring);
ret = krb_get_pw_in_tkt(princ->name, princ->instance, princ->realm,
@@ -489,8 +489,6 @@ siad_chg_password (sia_collect_func_t *collect,
char new_pw2[MAX_KPW_LEN+1];
static struct et_list *et_list;
- set_progname(argv[0]);
-
SIA_DEBUG(("DEBUG", "siad_chg_password"));
if(collect == NULL)
return SIADFAIL;
diff --git a/kerberosIV/src/lib/com_err/compile_et.c b/kerberosIV/src/lib/com_err/compile_et.c
index 3740effc0f3..ccdd445e6cf 100644
--- a/kerberosIV/src/lib/com_err/compile_et.c
+++ b/kerberosIV/src/lib/com_err/compile_et.c
@@ -196,7 +196,6 @@ main(int argc, char **argv)
char *p;
int optind = 0;
- set_progname(argv[0]);
if(getarg(args, num_args, argc, argv, &optind))
usage(1);
if(help_flag)
diff --git a/kerberosIV/src/lib/sl/make_cmds.c b/kerberosIV/src/lib/sl/make_cmds.c
index 6d074741d13..ee14ef2a387 100644
--- a/kerberosIV/src/lib/sl/make_cmds.c
+++ b/kerberosIV/src/lib/sl/make_cmds.c
@@ -213,7 +213,6 @@ main(int argc, char **argv)
{
int optind = 0;
- set_progname(argv[0]);
if(getarg(args, num_args, argc, argv, &optind))
usage(1);
if(help_flag)
diff --git a/kerberosIV/src/server/kerberos.c b/kerberosIV/src/server/kerberos.c
index f68c9f66b34..6ddc31365ee 100644
--- a/kerberosIV/src/server/kerberos.c
+++ b/kerberosIV/src/server/kerberos.c
@@ -719,8 +719,6 @@ main(int argc, char **argv)
umask(077); /* Create protected files */
- set_progname (argv[0]);
-
while ((c = getopt(argc, argv, "snmp:P:a:l:r:i:")) != -1) {
switch(c) {
case 's':
diff --git a/kerberosIV/src/slave/kprop.c b/kerberosIV/src/slave/kprop.c
index 08c45cd51bd..9cadbc44cba 100644
--- a/kerberosIV/src/slave/kprop.c
+++ b/kerberosIV/src/slave/kprop.c
@@ -405,8 +405,6 @@ main(int argc, char **argv)
static struct slave_host *slave_host_list = NULL;
struct slave_host *sh;
- set_progname (argv[0]);
-
transfer_mode = KPROP_TRANSFER_PRIVATE;
time(&l_init);