merge strcpy_truncate branch
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@5027 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -748,7 +748,7 @@ g_opendir(Char *str, glob_t *pglob)
|
|||||||
char buf[MaxPathLen];
|
char buf[MaxPathLen];
|
||||||
|
|
||||||
if (!*str)
|
if (!*str)
|
||||||
strcpy(buf, ".");
|
strcpy_truncate(buf, ".", sizeof(buf));
|
||||||
else
|
else
|
||||||
g_Ctoc(str, buf);
|
g_Ctoc(str, buf);
|
||||||
|
|
||||||
|
@@ -42,7 +42,7 @@ ftp_SOURCES = \
|
|||||||
domacro.c \
|
domacro.c \
|
||||||
ftp.c \
|
ftp.c \
|
||||||
globals.c \
|
globals.c \
|
||||||
kauth.c
|
kauth.c \
|
||||||
krb4.c \
|
krb4.c \
|
||||||
main.c \
|
main.c \
|
||||||
ruserpass.c \
|
ruserpass.c \
|
||||||
@@ -54,7 +54,7 @@ ftp_OBJS = \
|
|||||||
domacro.o \
|
domacro.o \
|
||||||
ftp.o \
|
ftp.o \
|
||||||
globals.o \
|
globals.o \
|
||||||
kauth.o
|
kauth.o \
|
||||||
krb4.o \
|
krb4.o \
|
||||||
main.o \
|
main.o \
|
||||||
ruserpass.o \
|
ruserpass.o \
|
||||||
|
@@ -119,12 +119,17 @@ setpeer(int argc, char **argv)
|
|||||||
/*
|
/*
|
||||||
* Set up defaults for FTP.
|
* Set up defaults for FTP.
|
||||||
*/
|
*/
|
||||||
strcpy(typename, "ascii"), type = TYPE_A;
|
strcpy_truncate(typename, "ascii", sizeof(typename));
|
||||||
|
type = TYPE_A;
|
||||||
curtype = TYPE_A;
|
curtype = TYPE_A;
|
||||||
strcpy(formname, "non-print"), form = FORM_N;
|
strcpy_truncate(formname, "non-print", sizeof(formname));
|
||||||
strcpy(modename, "stream"), mode = MODE_S;
|
form = FORM_N;
|
||||||
strcpy(structname, "file"), stru = STRU_F;
|
strcpy_truncate(modename, "stream", sizeof(modename));
|
||||||
strcpy(bytename, "8"), bytesize = 8;
|
mode = MODE_S;
|
||||||
|
strcpy_truncate(structname, "file", sizeof(structname));
|
||||||
|
stru = STRU_F;
|
||||||
|
strcpy_truncate(bytename, "8", sizeof(bytename));
|
||||||
|
bytesize = 8;
|
||||||
if (autologin)
|
if (autologin)
|
||||||
login(argv[1]);
|
login(argv[1]);
|
||||||
|
|
||||||
@@ -165,7 +170,7 @@ setpeer(int argc, char **argv)
|
|||||||
* for text files unless changed by the user.
|
* for text files unless changed by the user.
|
||||||
*/
|
*/
|
||||||
type = 0;
|
type = 0;
|
||||||
strcpy(typename, "binary");
|
strcpy_truncate(typename, "binary", sizeof(typename));
|
||||||
if (overbose)
|
if (overbose)
|
||||||
printf("Using %s mode to transfer files.\n",
|
printf("Using %s mode to transfer files.\n",
|
||||||
typename);
|
typename);
|
||||||
@@ -238,7 +243,7 @@ settype(int argc, char **argv)
|
|||||||
else
|
else
|
||||||
comret = command("TYPE %s", p->t_mode);
|
comret = command("TYPE %s", p->t_mode);
|
||||||
if (comret == COMPLETE) {
|
if (comret == COMPLETE) {
|
||||||
strcpy(typename, p->t_name);
|
strcpy_truncate(typename, p->t_name, sizeof(typename));
|
||||||
curtype = type = p->t_type;
|
curtype = type = p->t_type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -754,7 +759,7 @@ remglob(char **argv, int doswitch)
|
|||||||
}
|
}
|
||||||
if (ftemp == NULL) {
|
if (ftemp == NULL) {
|
||||||
int fd;
|
int fd;
|
||||||
strcpy(temp, _PATH_TMP_XXX);
|
strcpy_truncate(temp, _PATH_TMP_XXX, sizeof(temp));
|
||||||
fd = mkstemp(temp);
|
fd = mkstemp(temp);
|
||||||
if(fd < 0){
|
if(fd < 0){
|
||||||
warn("unable to create temporary file %s", temp);
|
warn("unable to create temporary file %s", temp);
|
||||||
@@ -1210,8 +1215,8 @@ shell(int argc, char **argv)
|
|||||||
namep = strrchr(shell,'/');
|
namep = strrchr(shell,'/');
|
||||||
if (namep == NULL)
|
if (namep == NULL)
|
||||||
namep = shell;
|
namep = shell;
|
||||||
strcpy(shellnam,"-");
|
snprintf (shellnam, sizeof(shellnam),
|
||||||
strcat(shellnam, ++namep);
|
"-%s", ++namep);
|
||||||
if (strcmp(namep, "sh") != 0)
|
if (strcmp(namep, "sh") != 0)
|
||||||
shellnam[0] = '+';
|
shellnam[0] = '+';
|
||||||
if (debug) {
|
if (debug) {
|
||||||
@@ -1386,17 +1391,14 @@ site(int argc, char **argv)
|
|||||||
void
|
void
|
||||||
quote1(char *initial, int argc, char **argv)
|
quote1(char *initial, int argc, char **argv)
|
||||||
{
|
{
|
||||||
int i, len;
|
int i;
|
||||||
char buf[BUFSIZ]; /* must be >= sizeof(line) */
|
char buf[BUFSIZ]; /* must be >= sizeof(line) */
|
||||||
|
|
||||||
strcpy(buf, initial);
|
strcpy_truncate(buf, initial, sizeof(buf));
|
||||||
if (argc > 1) {
|
for(i = 1; i < argc; i++) {
|
||||||
len = strlen(buf);
|
if(i > 1)
|
||||||
len += strlen(strcpy(&buf[len], argv[1]));
|
strcat_truncate(buf, " ", sizeof(buf));
|
||||||
for (i = 2; i < argc; i++) {
|
strcat_truncate(buf, argv[i], sizeof(buf));
|
||||||
buf[len++] = ' ';
|
|
||||||
len += strlen(strcpy(&buf[len], argv[i]));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (command(buf) == PRELIM) {
|
if (command(buf) == PRELIM) {
|
||||||
while (getreply(0) == PRELIM)
|
while (getreply(0) == PRELIM)
|
||||||
@@ -1548,12 +1550,11 @@ account(int argc, char **argv)
|
|||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
++argv;
|
++argv;
|
||||||
--argc;
|
--argc;
|
||||||
strncpy(acct,*argv,49);
|
strcpy_truncate (acct, *argv, sizeof(acct));
|
||||||
acct[49] = '\0';
|
|
||||||
while (argc > 1) {
|
while (argc > 1) {
|
||||||
--argc;
|
--argc;
|
||||||
++argv;
|
++argv;
|
||||||
strncat(acct,*argv, 49-strlen(acct));
|
strcat_truncate(acct, *argv, sizeof(acct));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -1665,14 +1666,12 @@ setntrans(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
ntflag++;
|
ntflag++;
|
||||||
code = ntflag;
|
code = ntflag;
|
||||||
strncpy(ntin, argv[1], 16);
|
strcpy_truncate (ntin, argv[1], 17);
|
||||||
ntin[16] = '\0';
|
|
||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
ntout[0] = '\0';
|
ntout[0] = '\0';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
strncpy(ntout, argv[2], 16);
|
strcpy_truncate (ntout, argv[2], 17);
|
||||||
ntout[16] = '\0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
@@ -1729,10 +1728,10 @@ setnmap(int argc, char **argv)
|
|||||||
cp = strchr(altarg, ' ');
|
cp = strchr(altarg, ' ');
|
||||||
}
|
}
|
||||||
*cp = '\0';
|
*cp = '\0';
|
||||||
strncpy(mapin, altarg, MaxPathLen - 1);
|
strcpy_truncate(mapin, altarg, MaxPathLen);
|
||||||
while (*++cp == ' ')
|
while (*++cp == ' ')
|
||||||
continue;
|
continue;
|
||||||
strncpy(mapout, cp, MaxPathLen - 1);
|
strcpy_truncate(mapout, cp, MaxPathLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
@@ -1984,7 +1983,9 @@ macdef(int argc, char **argv)
|
|||||||
if (interactive) {
|
if (interactive) {
|
||||||
printf("Enter macro line by line, terminating it with a null line\n");
|
printf("Enter macro line by line, terminating it with a null line\n");
|
||||||
}
|
}
|
||||||
strncpy(macros[macnum].mac_name, argv[1], 8);
|
strcpy_truncate(macros[macnum].mac_name,
|
||||||
|
argv[1],
|
||||||
|
sizeof(macros[macnum].mac_name));
|
||||||
if (macnum == 0) {
|
if (macnum == 0) {
|
||||||
macros[macnum].mac_start = macbuf;
|
macros[macnum].mac_start = macbuf;
|
||||||
}
|
}
|
||||||
|
@@ -56,7 +56,7 @@ domacro(int argc, char **argv)
|
|||||||
code = -1;
|
code = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
strcpy(line2, line);
|
strcpy_truncate(line2, line, sizeof(line2));
|
||||||
TOP:
|
TOP:
|
||||||
cp1 = macros[i].mac_start;
|
cp1 = macros[i].mac_start;
|
||||||
while (cp1 != macros[i].mac_end) {
|
while (cp1 != macros[i].mac_end) {
|
||||||
|
@@ -53,13 +53,13 @@ char *
|
|||||||
hookup(char *host, int port)
|
hookup(char *host, int port)
|
||||||
{
|
{
|
||||||
struct hostent *hp = 0;
|
struct hostent *hp = 0;
|
||||||
int s, len, tos;
|
int s, len;
|
||||||
static char hostnamebuf[80];
|
static char hostnamebuf[MaxHostNameLen];
|
||||||
|
|
||||||
memset(&hisctladdr, 0, sizeof (hisctladdr));
|
memset(&hisctladdr, 0, sizeof (hisctladdr));
|
||||||
if(inet_aton(host, &hisctladdr.sin_addr)){
|
if(inet_aton(host, &hisctladdr.sin_addr)){
|
||||||
hisctladdr.sin_family = AF_INET;
|
hisctladdr.sin_family = AF_INET;
|
||||||
strncpy(hostnamebuf, host, sizeof(hostnamebuf));
|
strcpy_truncate (hostnamebuf, host, sizeof (hostnamebuf));
|
||||||
} else {
|
} else {
|
||||||
hp = gethostbyname(host);
|
hp = gethostbyname(host);
|
||||||
if (hp == NULL) {
|
if (hp == NULL) {
|
||||||
@@ -71,8 +71,7 @@ hookup(char *host, int port)
|
|||||||
memmove(&hisctladdr.sin_addr,
|
memmove(&hisctladdr.sin_addr,
|
||||||
hp->h_addr_list[0],
|
hp->h_addr_list[0],
|
||||||
sizeof(hisctladdr.sin_addr));
|
sizeof(hisctladdr.sin_addr));
|
||||||
strncpy(hostnamebuf, hp->h_name, sizeof(hostnamebuf));
|
strcpy_truncate (hostnamebuf, hp->h_name, sizeof (hostnamebuf));
|
||||||
hostnamebuf[sizeof(hostnamebuf) - 1] = '\0';
|
|
||||||
}
|
}
|
||||||
hostname = hostnamebuf;
|
hostname = hostnamebuf;
|
||||||
s = socket(hisctladdr.sin_family, SOCK_STREAM, 0);
|
s = socket(hisctladdr.sin_family, SOCK_STREAM, 0);
|
||||||
@@ -116,9 +115,12 @@ hookup(char *host, int port)
|
|||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
#if defined(IP_TOS) && defined(HAVE_SETSOCKOPT)
|
#if defined(IP_TOS) && defined(HAVE_SETSOCKOPT)
|
||||||
tos = IPTOS_LOWDELAY;
|
{
|
||||||
|
int tos = IPTOS_LOWDELAY;
|
||||||
|
|
||||||
if (setsockopt(s, IPPROTO_IP, IP_TOS, (char *)&tos, sizeof(int)) < 0)
|
if (setsockopt(s, IPPROTO_IP, IP_TOS, (char *)&tos, sizeof(int)) < 0)
|
||||||
warn("setsockopt TOS (ignored)");
|
warn("setsockopt TOS (ignored)");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
cin = fdopen(s, "r");
|
cin = fdopen(s, "r");
|
||||||
cout = fdopen(s, "w");
|
cout = fdopen(s, "w");
|
||||||
@@ -168,6 +170,7 @@ login(char *host)
|
|||||||
|
|
||||||
char *myname = NULL;
|
char *myname = NULL;
|
||||||
struct passwd *pw = k_getpwuid(getuid());
|
struct passwd *pw = k_getpwuid(getuid());
|
||||||
|
|
||||||
if (pw != NULL)
|
if (pw != NULL)
|
||||||
myname = pw->pw_name;
|
myname = pw->pw_name;
|
||||||
|
|
||||||
@@ -195,7 +198,7 @@ login(char *host)
|
|||||||
else
|
else
|
||||||
user = tmp;
|
user = tmp;
|
||||||
}
|
}
|
||||||
strcpy(username, user);
|
strcpy_truncate(username, user, sizeof(username));
|
||||||
n = command("USER %s", user);
|
n = command("USER %s", user);
|
||||||
if (n == CONTINUE) {
|
if (n == CONTINUE) {
|
||||||
if(sec_complete)
|
if(sec_complete)
|
||||||
@@ -204,10 +207,12 @@ login(char *host)
|
|||||||
char prompt[128];
|
char prompt[128];
|
||||||
if(myname &&
|
if(myname &&
|
||||||
(!strcmp(user, "ftp") || !strcmp(user, "anonymous"))){
|
(!strcmp(user, "ftp") || !strcmp(user, "anonymous"))){
|
||||||
snprintf(defaultpass, sizeof(defaultpass), "%s@%s", myname, mydomain);
|
snprintf(defaultpass, sizeof(defaultpass),
|
||||||
snprintf(prompt, sizeof(prompt), "Password (%s): ", defaultpass);
|
"%s@%s", myname, mydomain);
|
||||||
|
snprintf(prompt, sizeof(prompt),
|
||||||
|
"Password (%s): ", defaultpass);
|
||||||
}else{
|
}else{
|
||||||
strcpy(defaultpass, "");
|
*defaultpass = '\0';
|
||||||
snprintf(prompt, sizeof(prompt), "Password: ");
|
snprintf(prompt, sizeof(prompt), "Password: ");
|
||||||
}
|
}
|
||||||
pass = defaultpass;
|
pass = defaultpass;
|
||||||
@@ -233,7 +238,7 @@ login(char *host)
|
|||||||
return (1);
|
return (1);
|
||||||
for (n = 0; n < macnum; ++n) {
|
for (n = 0; n < macnum; ++n) {
|
||||||
if (!strcmp("init", macros[n].mac_name)) {
|
if (!strcmp("init", macros[n].mac_name)) {
|
||||||
strcpy(line, "$init");
|
strcpy_truncate (line, "$init", sizeof (line));
|
||||||
makeargv();
|
makeargv();
|
||||||
domacro(margc, margv);
|
domacro(margc, margv);
|
||||||
break;
|
break;
|
||||||
@@ -337,7 +342,7 @@ getreply(int expecteof)
|
|||||||
fprintf(cout, "%c%c%c", IAC, WONT, getc(cin));
|
fprintf(cout, "%c%c%c", IAC, WONT, getc(cin));
|
||||||
continue;
|
continue;
|
||||||
case '\n':
|
case '\n':
|
||||||
*p++ = 0;
|
*p++ = '\0';
|
||||||
if(isdigit(buf[0])){
|
if(isdigit(buf[0])){
|
||||||
sscanf(buf, "%d", &code);
|
sscanf(buf, "%d", &code);
|
||||||
if(code == 631){
|
if(code == 631){
|
||||||
@@ -373,13 +378,14 @@ getreply(int expecteof)
|
|||||||
#endif
|
#endif
|
||||||
if(code == 227){
|
if(code == 227){
|
||||||
char *p, *q;
|
char *p, *q;
|
||||||
|
|
||||||
pasv[0] = 0;
|
pasv[0] = 0;
|
||||||
p = strchr(reply_string, '(');
|
p = strchr(reply_string, '(');
|
||||||
if(p){
|
if(p){
|
||||||
p++;
|
p++;
|
||||||
q = strchr(p, ')');
|
q = strchr(p, ')');
|
||||||
if(q){
|
if(q){
|
||||||
strncpy(pasv, p, q - p);
|
memcpy (pasv, p, q - p);
|
||||||
pasv[q - p] = 0;
|
pasv[q - p] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -503,7 +509,6 @@ getreply(int expecteof)
|
|||||||
sec_read_msg(reply_string, prot_confidential);
|
sec_read_msg(reply_string, prot_confidential);
|
||||||
n = code / 100 + '0';
|
n = code / 100 + '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n != '1')
|
if (n != '1')
|
||||||
cpend = 0;
|
cpend = 0;
|
||||||
signal(SIGINT,oldintr);
|
signal(SIGINT,oldintr);
|
||||||
@@ -514,6 +519,7 @@ getreply(int expecteof)
|
|||||||
return (n - '0');
|
return (n - '0');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -608,6 +614,7 @@ sendrequest(char *cmd, char *local, char *remote, int printnames)
|
|||||||
int c, d;
|
int c, d;
|
||||||
FILE *fin, *dout = 0;
|
FILE *fin, *dout = 0;
|
||||||
int (*closefunc) (FILE *);
|
int (*closefunc) (FILE *);
|
||||||
|
|
||||||
RETSIGTYPE (*oldintr)(), (*oldintp)();
|
RETSIGTYPE (*oldintr)(), (*oldintp)();
|
||||||
long bytes = 0, hashbytes = HASHBYTES;
|
long bytes = 0, hashbytes = HASHBYTES;
|
||||||
char *lmode;
|
char *lmode;
|
||||||
@@ -726,8 +733,7 @@ sendrequest(char *cmd, char *local, char *remote, int printnames)
|
|||||||
(*closefunc)(fin);
|
(*closefunc)(fin);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else
|
} else if (command ("%s", cmd) != PRELIM) {
|
||||||
if (command("%s", cmd) != PRELIM) {
|
|
||||||
signal(SIGINT, oldintr);
|
signal(SIGINT, oldintr);
|
||||||
if (oldintp)
|
if (oldintp)
|
||||||
signal(SIGPIPE, oldintp);
|
signal(SIGPIPE, oldintp);
|
||||||
@@ -906,8 +912,7 @@ recvrequest(char *cmd, char *local, char *remote,
|
|||||||
code = -1;
|
code = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} else if (runique && (local = gunique (local)) == NULL) {
|
||||||
else if (runique && (local = gunique(local)) == NULL) {
|
|
||||||
signal(SIGINT, oldintr);
|
signal(SIGINT, oldintr);
|
||||||
code = -1;
|
code = -1;
|
||||||
return;
|
return;
|
||||||
@@ -1031,7 +1036,6 @@ recvrequest(char *cmd, char *local, char *remote,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((c = sec_getc(din)) != EOF) {
|
while ((c = sec_getc(din)) != EOF) {
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
bare_lfs++;
|
bare_lfs++;
|
||||||
@@ -1102,7 +1106,6 @@ abort:
|
|||||||
signal(SIGINT, oldintr);
|
signal(SIGINT, oldintr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
abort_remote(din);
|
abort_remote(din);
|
||||||
code = -1;
|
code = -1;
|
||||||
if (data >= 0) {
|
if (data >= 0) {
|
||||||
@@ -1148,11 +1151,10 @@ initconn(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* What we've got at this point is a string of comma
|
* What we've got at this point is a string of comma separated
|
||||||
* separated one-byte unsigned integer values.
|
* one-byte unsigned integer values. The first four are the an IP
|
||||||
* The first four are the an IP address. The fifth is
|
* address. The fifth is the MSB of the port number, the sixth is the
|
||||||
* the MSB of the port number, the sixth is the LSB.
|
* LSB. From that we'll prepare a sockaddr_in.
|
||||||
* From that we'll prepare a sockaddr_in.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (sscanf(pasv,"%d,%d,%d,%d,%d,%d",
|
if (sscanf(pasv,"%d,%d,%d,%d,%d,%d",
|
||||||
@@ -1170,7 +1172,6 @@ initconn(void)
|
|||||||
printf("Can't parse passive mode string.\n");
|
printf("Can't parse passive mode string.\n");
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&data_addr, 0, sizeof(data_addr));
|
memset(&data_addr, 0, sizeof(data_addr));
|
||||||
data_addr.sin_family = AF_INET;
|
data_addr.sin_family = AF_INET;
|
||||||
data_addr.sin_addr.s_addr = htonl((a0 << 24) | (a1 << 16) |
|
data_addr.sin_addr.s_addr = htonl((a0 << 24) | (a1 << 16) |
|
||||||
@@ -1190,7 +1191,6 @@ initconn(void)
|
|||||||
#endif
|
#endif
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
noport:
|
noport:
|
||||||
data_addr = myctladdr;
|
data_addr = myctladdr;
|
||||||
if (sendport)
|
if (sendport)
|
||||||
@@ -1230,6 +1230,7 @@ noport:
|
|||||||
if (sendport) {
|
if (sendport) {
|
||||||
unsigned int a = ntohl(data_addr.sin_addr.s_addr);
|
unsigned int a = ntohl(data_addr.sin_addr.s_addr);
|
||||||
unsigned int p = ntohs(data_addr.sin_port);
|
unsigned int p = ntohs(data_addr.sin_port);
|
||||||
|
|
||||||
result = command("PORT %d,%d,%d,%d,%d,%d",
|
result = command("PORT %d,%d,%d,%d,%d,%d",
|
||||||
(a >> 24) & 0xff,
|
(a >> 24) & 0xff,
|
||||||
(a >> 16) & 0xff,
|
(a >> 16) & 0xff,
|
||||||
@@ -1372,8 +1373,7 @@ pswitch(int flag)
|
|||||||
ip->connect = connected;
|
ip->connect = connected;
|
||||||
connected = op->connect;
|
connected = op->connect;
|
||||||
if (hostname) {
|
if (hostname) {
|
||||||
strncpy(ip->name, hostname, sizeof(ip->name) - 1);
|
strcpy_truncate (ip->name, hostname, sizeof (ip->name));
|
||||||
ip->name[strlen(ip->name)] = '\0';
|
|
||||||
} else
|
} else
|
||||||
ip->name[0] = 0;
|
ip->name[0] = 0;
|
||||||
hostname = op->name;
|
hostname = op->name;
|
||||||
@@ -1399,20 +1399,16 @@ pswitch(int flag)
|
|||||||
mcase = op->mcse;
|
mcase = op->mcse;
|
||||||
ip->ntflg = ntflag;
|
ip->ntflg = ntflag;
|
||||||
ntflag = op->ntflg;
|
ntflag = op->ntflg;
|
||||||
strncpy(ip->nti, ntin, 16);
|
strcpy_truncate (ip->nti, ntin, sizeof (ip->nti));
|
||||||
(ip->nti)[strlen(ip->nti)] = '\0';
|
strcpy_truncate (ntin, op->nti, 17);
|
||||||
strcpy(ntin, op->nti);
|
strcpy_truncate (ip->nto, ntout, sizeof (ip->nto));
|
||||||
strncpy(ip->nto, ntout, 16);
|
strcpy_truncate (ntout, op->nto, 17);
|
||||||
(ip->nto)[strlen(ip->nto)] = '\0';
|
|
||||||
strcpy(ntout, op->nto);
|
|
||||||
ip->mapflg = mapflag;
|
ip->mapflg = mapflag;
|
||||||
mapflag = op->mapflg;
|
mapflag = op->mapflg;
|
||||||
strncpy(ip->mi, mapin, MaxPathLen - 1);
|
strcpy_truncate (ip->mi, mapin, MaxPathLen);
|
||||||
(ip->mi)[strlen(ip->mi)] = '\0';
|
strcpy_truncate (mapin, op->mi, MaxPathLen);
|
||||||
strcpy(mapin, op->mi);
|
strcpy_truncate (ip->mo, mapout, MaxPathLen);
|
||||||
strncpy(ip->mo, mapout, MaxPathLen - 1);
|
strcpy_truncate (mapout, op->mo, MaxPathLen);
|
||||||
(ip->mo)[strlen(ip->mo)] = '\0';
|
|
||||||
strcpy(mapout, op->mo);
|
|
||||||
signal(SIGINT, oldintr);
|
signal(SIGINT, oldintr);
|
||||||
if (abrtflag) {
|
if (abrtflag) {
|
||||||
abrtflag = 0;
|
abrtflag = 0;
|
||||||
@@ -1563,8 +1559,7 @@ reset(int argc, char **argv)
|
|||||||
warn("reset");
|
warn("reset");
|
||||||
code = -1;
|
code = -1;
|
||||||
lostpeer(0);
|
lostpeer(0);
|
||||||
}
|
} else if (nfnd) {
|
||||||
else if (nfnd) {
|
|
||||||
getreply(0);
|
getreply(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1587,7 +1582,7 @@ gunique(char *local)
|
|||||||
warn("local: %s", local);
|
warn("local: %s", local);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
strcpy(new, local);
|
strcpy_truncate (new, local, sizeof(new));
|
||||||
cp = new + strlen(new);
|
cp = new + strlen(new);
|
||||||
*cp++ = '.';
|
*cp++ = '.';
|
||||||
while (!d) {
|
while (!d) {
|
||||||
|
@@ -146,14 +146,14 @@ krb4_adat(void *app_data, void *buf, size_t len)
|
|||||||
memcpy(d->key, auth_dat.session, sizeof(d->key));
|
memcpy(d->key, auth_dat.session, sizeof(d->key));
|
||||||
des_set_key(&d->key, d->schedule);
|
des_set_key(&d->key, d->schedule);
|
||||||
|
|
||||||
strcpy(d->name, auth_dat.pname);
|
strcpy_truncate(d->name, auth_dat.pname, sizeof(d->name));
|
||||||
strcpy(d->instance, auth_dat.pinst);
|
strcpy_truncate(d->instance, auth_dat.pinst, sizeof(d->instance));
|
||||||
strcpy(d->realm, auth_dat.prealm);
|
strcpy_truncate(d->realm, auth_dat.prealm, sizeof(d->instance));
|
||||||
|
|
||||||
cs = auth_dat.checksum + 1;
|
cs = auth_dat.checksum + 1;
|
||||||
{
|
{
|
||||||
unsigned char tmp[4];
|
unsigned char tmp[4];
|
||||||
krb_put_int(cs, tmp, 4);
|
krb_put_int(cs, tmp, 4, sizeof(tmp));
|
||||||
len = krb_mk_safe(tmp, msg, 4, &d->key, &LOCAL_ADDR, &REMOTE_ADDR);
|
len = krb_mk_safe(tmp, msg, 4, &d->key, &LOCAL_ADDR, &REMOTE_ADDR);
|
||||||
}
|
}
|
||||||
if(len < 0){
|
if(len < 0){
|
||||||
@@ -203,15 +203,15 @@ mk_auth(struct krb4_data *d, KTEXT adat,
|
|||||||
int ret;
|
int ret;
|
||||||
CREDENTIALS cred;
|
CREDENTIALS cred;
|
||||||
char sname[SNAME_SZ], inst[INST_SZ], realm[REALM_SZ];
|
char sname[SNAME_SZ], inst[INST_SZ], realm[REALM_SZ];
|
||||||
strcpy(sname, service);
|
strcpy_truncate(sname, service, sizeof(sname));
|
||||||
strcpy(inst, krb_get_phost(host));
|
strcpy_truncate(inst, krb_get_phost(host), sizeof(inst));
|
||||||
strcpy(realm, krb_realmofhost(host));
|
strcpy_truncate(realm, krb_realmofhost(host), sizeof(realm));
|
||||||
ret = krb_mk_req(adat, sname, inst, realm, checksum);
|
ret = krb_mk_req(adat, sname, inst, realm, checksum);
|
||||||
if(ret)
|
if(ret)
|
||||||
return ret;
|
return ret;
|
||||||
strcpy(sname, service);
|
strcpy_truncate(sname, service, sizeof(sname));
|
||||||
strcpy(inst, krb_get_phost(host));
|
strcpy_truncate(inst, krb_get_phost(host), sizeof(inst));
|
||||||
strcpy(realm, krb_realmofhost(host));
|
strcpy_truncate(realm, krb_realmofhost(host), sizeof(realm));
|
||||||
ret = krb_get_cred(sname, inst, realm, &cred);
|
ret = krb_get_cred(sname, inst, realm, &cred);
|
||||||
memmove(&d->key, &cred.session, sizeof(des_cblock));
|
memmove(&d->key, &cred.session, sizeof(des_cblock));
|
||||||
des_key_sched(&d->key, d->schedule);
|
des_key_sched(&d->key, d->schedule);
|
||||||
|
@@ -104,8 +104,8 @@ main(int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
pw = k_getpwuid(getuid());
|
pw = k_getpwuid(getuid());
|
||||||
if (pw != NULL) {
|
if (pw != NULL) {
|
||||||
|
strcpy_truncate(homedir, pw->pw_dir, sizeof(homedir));
|
||||||
home = homedir;
|
home = homedir;
|
||||||
strcpy(home, pw->pw_dir);
|
|
||||||
}
|
}
|
||||||
if (argc > 0) {
|
if (argc > 0) {
|
||||||
char *xargv[5];
|
char *xargv[5];
|
||||||
@@ -243,8 +243,7 @@ cmdscanner(int top)
|
|||||||
p = readline("ftp> ");
|
p = readline("ftp> ");
|
||||||
if(p == NULL)
|
if(p == NULL)
|
||||||
quit(0, 0);
|
quit(0, 0);
|
||||||
strncpy(line, p, sizeof(line));
|
strcpy_truncate(line, p, sizeof(line));
|
||||||
line[sizeof(line) - 1] = 0;
|
|
||||||
add_history(p);
|
add_history(p);
|
||||||
free(p);
|
free(p);
|
||||||
} else{
|
} else{
|
||||||
|
@@ -71,7 +71,7 @@ ruserpass(char *host, char **aname, char **apass, char **aacct)
|
|||||||
struct stat stb;
|
struct stat stb;
|
||||||
|
|
||||||
if(gethostname(myhostname, MaxHostNameLen) < 0)
|
if(gethostname(myhostname, MaxHostNameLen) < 0)
|
||||||
strcpy(myhostname, "");
|
strcpy_truncate(myhostname, "", MaxHostNameLen);
|
||||||
if((mydomain = strchr(myhostname, '.')) == NULL)
|
if((mydomain = strchr(myhostname, '.')) == NULL)
|
||||||
mydomain = myhostname;
|
mydomain = myhostname;
|
||||||
else
|
else
|
||||||
|
@@ -23,6 +23,8 @@ MKINSTALLDIRS = $(top_srcdir)/mkinstalldirs
|
|||||||
INSTALL = @INSTALL@
|
INSTALL = @INSTALL@
|
||||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||||
|
|
||||||
|
LN_S = @LN_S@
|
||||||
|
|
||||||
prefix = @prefix@
|
prefix = @prefix@
|
||||||
exec_prefix = @exec_prefix@
|
exec_prefix = @exec_prefix@
|
||||||
libdir = @libdir@
|
libdir = @libdir@
|
||||||
@@ -64,7 +66,7 @@ gssapi.c:
|
|||||||
$(LN_S) $(srcdir)/../ftp/gssapi.c .
|
$(LN_S) $(srcdir)/../ftp/gssapi.c .
|
||||||
|
|
||||||
.c.o:
|
.c.o:
|
||||||
$(CC) -c -DFTP_SERVER -I$(srcdir) -I$(srcdir)/../common -I$(INCTOP) $(DEFS) $(CFLAGS) $(CPPFLAGS) $<
|
$(CC) -c -DFTP_SERVER -I. -I$(srcdir) -I$(srcdir)/../common -I$(INCTOP) $(DEFS) $(CFLAGS) $(CPPFLAGS) $<
|
||||||
|
|
||||||
install: all
|
install: all
|
||||||
$(MKINSTALLDIRS) $(DESTDIR)$(libexecdir)
|
$(MKINSTALLDIRS) $(DESTDIR)$(libexecdir)
|
||||||
|
@@ -326,11 +326,11 @@ cmd
|
|||||||
{
|
{
|
||||||
if(oobflag){
|
if(oobflag){
|
||||||
if (file_size != (off_t) -1)
|
if (file_size != (off_t) -1)
|
||||||
reply(213, "Status: %ld of %ld bytes transferred",
|
reply(213, "Status: %lu of %lu bytes transferred",
|
||||||
(unsigned long)byte_count,
|
(unsigned long)byte_count,
|
||||||
(unsigned long)file_size);
|
(unsigned long)file_size);
|
||||||
else
|
else
|
||||||
reply(213, "Status: %ld bytes transferred",
|
reply(213, "Status: %lu bytes transferred",
|
||||||
(unsigned long)byte_count);
|
(unsigned long)byte_count);
|
||||||
}else
|
}else
|
||||||
statcmd();
|
statcmd();
|
||||||
@@ -999,7 +999,7 @@ getline(char *s, int n)
|
|||||||
cs = s;
|
cs = s;
|
||||||
/* tmpline may contain saved command from urgent mode interruption */
|
/* tmpline may contain saved command from urgent mode interruption */
|
||||||
if(ftp_command){
|
if(ftp_command){
|
||||||
strncpy(s, ftp_command, n);
|
strcpy_truncate(s, ftp_command, n);
|
||||||
if (debug)
|
if (debug)
|
||||||
syslog(LOG_DEBUG, "command: %s", s);
|
syslog(LOG_DEBUG, "command: %s", s);
|
||||||
#ifdef XXX
|
#ifdef XXX
|
||||||
@@ -1338,16 +1338,21 @@ help(struct tab *ctab, char *s)
|
|||||||
columns = 1;
|
columns = 1;
|
||||||
lines = (NCMDS + columns - 1) / columns;
|
lines = (NCMDS + columns - 1) / columns;
|
||||||
for (i = 0; i < lines; i++) {
|
for (i = 0; i < lines; i++) {
|
||||||
strcpy (buf, " ");
|
strcpy_truncate (buf, " ", sizeof(buf));
|
||||||
for (j = 0; j < columns; j++) {
|
for (j = 0; j < columns; j++) {
|
||||||
c = ctab + j * lines + i;
|
c = ctab + j * lines + i;
|
||||||
snprintf (buf + strlen(buf), sizeof(buf) - strlen(buf),
|
snprintf (buf + strlen(buf),
|
||||||
"%s%c", c->name, c->implemented ? ' ' : '*');
|
sizeof(buf) - strlen(buf),
|
||||||
|
"%s%c",
|
||||||
|
c->name,
|
||||||
|
c->implemented ? ' ' : '*');
|
||||||
if (c + lines >= &ctab[NCMDS])
|
if (c + lines >= &ctab[NCMDS])
|
||||||
break;
|
break;
|
||||||
w = strlen(c->name) + 1;
|
w = strlen(c->name) + 1;
|
||||||
while (w < width) {
|
while (w < width) {
|
||||||
strcat(buf, " ");
|
strcat_truncate (buf,
|
||||||
|
" ",
|
||||||
|
sizeof(buf));
|
||||||
w++;
|
w++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1405,7 +1410,7 @@ sizecmd(char *filename)
|
|||||||
}
|
}
|
||||||
fclose(fin);
|
fclose(fin);
|
||||||
|
|
||||||
reply(213, "%ld", (unsigned long)count);
|
reply(213, "%lu", (unsigned long)count);
|
||||||
break; }
|
break; }
|
||||||
default:
|
default:
|
||||||
reply(504, "SIZE not implemented for Type %c.", "?AEIL"[type]);
|
reply(504, "SIZE not implemented for Type %c.", "?AEIL"[type]);
|
||||||
|
@@ -135,12 +135,12 @@ static void usage(void);
|
|||||||
static char *
|
static char *
|
||||||
curdir(void)
|
curdir(void)
|
||||||
{
|
{
|
||||||
static char path[MaxPathLen+1+1]; /* path + '/' + '\0' */
|
static char path[MaxPathLen+1]; /* path + '/' + '\0' */
|
||||||
|
|
||||||
if (getcwd(path, sizeof(path)-2) == NULL)
|
if (getcwd(path, sizeof(path)-1) == NULL)
|
||||||
return ("");
|
return ("");
|
||||||
if (path[1] != '\0') /* special case for root dir. */
|
if (path[1] != '\0') /* special case for root dir. */
|
||||||
strcat(path, "/");
|
strcat_truncate(path, "/", sizeof(path));
|
||||||
/* For guest account, skip / since it's chrooted */
|
/* For guest account, skip / since it's chrooted */
|
||||||
return (guest ? path+1 : path);
|
return (guest ? path+1 : path);
|
||||||
}
|
}
|
||||||
@@ -530,7 +530,7 @@ user(char *name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (logging)
|
if (logging)
|
||||||
strncpy(curname, name, sizeof(curname)-1);
|
strcpy_truncate(curname, name, sizeof(curname));
|
||||||
if(sec_complete) {
|
if(sec_complete) {
|
||||||
if(sec_userok(name) == 0)
|
if(sec_userok(name) == 0)
|
||||||
do_login(232, name);
|
do_login(232, name);
|
||||||
@@ -1092,14 +1092,14 @@ dataconn(char *name, off_t size, char *mode)
|
|||||||
{
|
{
|
||||||
char sizebuf[32];
|
char sizebuf[32];
|
||||||
FILE *file;
|
FILE *file;
|
||||||
int retry = 0, tos;
|
int retry = 0;
|
||||||
|
|
||||||
file_size = size;
|
file_size = size;
|
||||||
byte_count = 0;
|
byte_count = 0;
|
||||||
if (size >= 0)
|
if (size >= 0)
|
||||||
snprintf(sizebuf, sizeof(sizebuf), " (%ld bytes)", (long)size);
|
snprintf(sizebuf, sizeof(sizebuf), " (%ld bytes)", (long)size);
|
||||||
else
|
else
|
||||||
strcpy(sizebuf, "");
|
*sizebuf = '\0';
|
||||||
if (pdata >= 0) {
|
if (pdata >= 0) {
|
||||||
struct sockaddr_in from;
|
struct sockaddr_in from;
|
||||||
int s, fromlen = sizeof(from);
|
int s, fromlen = sizeof(from);
|
||||||
@@ -1114,9 +1114,12 @@ dataconn(char *name, off_t size, char *mode)
|
|||||||
close(pdata);
|
close(pdata);
|
||||||
pdata = s;
|
pdata = s;
|
||||||
#if defined(IP_TOS) && defined(HAVE_SETSOCKOPT)
|
#if defined(IP_TOS) && defined(HAVE_SETSOCKOPT)
|
||||||
tos = IPTOS_THROUGHPUT;
|
{
|
||||||
setsockopt(s, IPPROTO_IP, IP_TOS, (void *)&tos,
|
int tos = IPTOS_THROUGHPUT;
|
||||||
sizeof(int));
|
|
||||||
|
setsockopt(s, IPPROTO_IP, IP_TOS, (void *)&tos,
|
||||||
|
sizeof(tos));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
reply(150, "Opening %s mode data connection for '%s'%s.",
|
reply(150, "Opening %s mode data connection for '%s'%s.",
|
||||||
type == TYPE_A ? "ASCII" : "BINARY", name, sizebuf);
|
type == TYPE_A ? "ASCII" : "BINARY", name, sizebuf);
|
||||||
@@ -1608,7 +1611,7 @@ removedir(char *name)
|
|||||||
void
|
void
|
||||||
pwd(void)
|
pwd(void)
|
||||||
{
|
{
|
||||||
char path[MaxPathLen + 1];
|
char path[MaxPathLen];
|
||||||
char *ret;
|
char *ret;
|
||||||
|
|
||||||
/* SunOS has a broken getcwd that does popen(pwd) (!!!), this
|
/* SunOS has a broken getcwd that does popen(pwd) (!!!), this
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1995, 1996, 1997 Kungliga Tekniska H<>gskolan
|
* Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska H<>gskolan
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -66,7 +66,7 @@ store_ticket(KTEXT cip)
|
|||||||
unsigned char kvno;
|
unsigned char kvno;
|
||||||
KTEXT_ST tkt;
|
KTEXT_ST tkt;
|
||||||
int left = cip->length;
|
int left = cip->length;
|
||||||
|
int len;
|
||||||
int kerror;
|
int kerror;
|
||||||
|
|
||||||
ptr = (char *) cip->dat;
|
ptr = (char *) cip->dat;
|
||||||
@@ -76,29 +76,32 @@ store_ticket(KTEXT cip)
|
|||||||
ptr += 8;
|
ptr += 8;
|
||||||
left -= 8;
|
left -= 8;
|
||||||
|
|
||||||
if (strnlen(ptr, left) == left)
|
len = strnlen(ptr, left);
|
||||||
|
if (len == left)
|
||||||
return(INTK_BADPW);
|
return(INTK_BADPW);
|
||||||
|
|
||||||
/* extract server's name */
|
/* extract server's name */
|
||||||
strcpy(sp.name, ptr);
|
strcpy_truncate(sp.name, ptr, sizeof(sp.name));
|
||||||
ptr += strlen(sp.name) + 1;
|
ptr += len + 1;
|
||||||
left -= strlen(sp.name) + 1;
|
left -= len + 1;
|
||||||
|
|
||||||
if (strnlen(ptr, left) == left)
|
len = strnlen(ptr, left);
|
||||||
|
if (len == left)
|
||||||
return(INTK_BADPW);
|
return(INTK_BADPW);
|
||||||
|
|
||||||
/* extract server's instance */
|
/* extract server's instance */
|
||||||
strcpy(sp.instance, ptr);
|
strcpy_truncate(sp.instance, ptr, sizeof(sp.instance));
|
||||||
ptr += strlen(sp.instance) + 1;
|
ptr += len + 1;
|
||||||
left -= strlen(sp.instance) + 1;
|
left -= len + 1;
|
||||||
|
|
||||||
if (strnlen(ptr, left) == left)
|
len = strnlen(ptr, left);
|
||||||
|
if (len == left)
|
||||||
return(INTK_BADPW);
|
return(INTK_BADPW);
|
||||||
|
|
||||||
/* extract server's realm */
|
/* extract server's realm */
|
||||||
strcpy(sp.realm,ptr);
|
strcpy_truncate(sp.realm, ptr, sizeof(sp.realm));
|
||||||
ptr += strlen(sp.realm) + 1;
|
ptr += len + 1;
|
||||||
left -= strlen(sp.realm) + 1;
|
left -= len + 1;
|
||||||
|
|
||||||
if(left < 3)
|
if(left < 3)
|
||||||
return INTK_BADPW;
|
return INTK_BADPW;
|
||||||
@@ -297,12 +300,12 @@ klist(void)
|
|||||||
" Issued", " Expires", " Principal (kvno)");
|
" Issued", " Expires", " Principal (kvno)");
|
||||||
header = 0;
|
header = 0;
|
||||||
}
|
}
|
||||||
strcpy(buf1, short_date(c.issue_date));
|
strcpy_truncate(buf1, short_date(c.issue_date), sizeof(buf1));
|
||||||
c.issue_date = krb_life_to_time(c.issue_date, c.lifetime);
|
c.issue_date = krb_life_to_time(c.issue_date, c.lifetime);
|
||||||
if (time(0) < (unsigned long) c.issue_date)
|
if (time(0) < (unsigned long) c.issue_date)
|
||||||
strcpy(buf2, short_date(c.issue_date));
|
strcpy_truncate(buf2, short_date(c.issue_date), sizeof(buf2));
|
||||||
else
|
else
|
||||||
strcpy(buf2, ">>> Expired <<< ");
|
strcpy_truncate(buf2, ">>> Expired <<< ", sizeof(buf2));
|
||||||
lreply(200, "%s %s %s (%d)", buf1, buf2,
|
lreply(200, "%s %s %s (%d)", buf1, buf2,
|
||||||
krb_unparse_name_long(c.service, c.instance, c.realm), c.kvno);
|
krb_unparse_name_long(c.service, c.instance, c.realm), c.kvno);
|
||||||
}
|
}
|
||||||
|
@@ -89,10 +89,10 @@ ftp_rooted(const char *path)
|
|||||||
|
|
||||||
if(!home[0])
|
if(!home[0])
|
||||||
if((pwd = k_getpwnam("ftp")))
|
if((pwd = k_getpwnam("ftp")))
|
||||||
strcpy(home, pwd->pw_dir);
|
strcpy_truncate(home, pwd->pw_dir, sizeof(home));
|
||||||
snprintf(newpath, sizeof(newpath), "%s/%s", home, path);
|
snprintf(newpath, sizeof(newpath), "%s/%s", home, path);
|
||||||
if(access(newpath, X_OK))
|
if(access(newpath, X_OK))
|
||||||
strcpy(newpath, path);
|
strcpy_truncate(newpath, path, sizeof(newpath));
|
||||||
return newpath;
|
return newpath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -325,8 +325,7 @@ create_and_write_cookie (char *xauthfile,
|
|||||||
auth.data = (char*)cookie;
|
auth.data = (char*)cookie;
|
||||||
des_rand_data (cookie, sz);
|
des_rand_data (cookie, sz);
|
||||||
|
|
||||||
strncpy(xauthfile, "/tmp/AXXXXXX", size);
|
strcpy_truncate(xauthfile, "/tmp/AXXXXXX", size);
|
||||||
xauthfile[size-1] = 0;
|
|
||||||
fd = mkstemp(xauthfile);
|
fd = mkstemp(xauthfile);
|
||||||
if(fd < 0) {
|
if(fd < 0) {
|
||||||
syslog(LOG_ERR, "create_and_write_cookie: mkstemp: %m");
|
syslog(LOG_ERR, "create_and_write_cookie: mkstemp: %m");
|
||||||
|
56
appl/kx/kx.c
56
appl/kx/kx.c
@@ -236,8 +236,8 @@ doit_passive (char *host, char *user, int debugp, int keepalivep,
|
|||||||
p = msg;
|
p = msg;
|
||||||
*p++ = INIT;
|
*p++ = INIT;
|
||||||
len = strlen(user);
|
len = strlen(user);
|
||||||
p += krb_put_int (len, p, 4);
|
p += krb_put_int (len, p, sizeof(msg) - 1, 4);
|
||||||
strncpy(p, user, len);
|
memcpy(p, user, len);
|
||||||
p += len;
|
p += len;
|
||||||
*p++ = PASSIVE | (keepalivep ? KEEP_ALIVE : 0);
|
*p++ = PASSIVE | (keepalivep ? KEEP_ALIVE : 0);
|
||||||
if (write_encrypted (otherside, msg, p - msg, schedule,
|
if (write_encrypted (otherside, msg, p - msg, schedule,
|
||||||
@@ -260,12 +260,12 @@ doit_passive (char *host, char *user, int debugp, int keepalivep,
|
|||||||
} else
|
} else
|
||||||
p++;
|
p++;
|
||||||
p += krb_get_int (p, &tmp, 4, 0);
|
p += krb_get_int (p, &tmp, 4, 0);
|
||||||
strncpy(display, p, tmp);
|
memcpy(display, p, tmp);
|
||||||
display[tmp] = '\0';
|
display[tmp] = '\0';
|
||||||
p += tmp;
|
p += tmp;
|
||||||
|
|
||||||
p += krb_get_int (p, &tmp, 4, 0);
|
p += krb_get_int (p, &tmp, 4, 0);
|
||||||
strncpy(xauthfile, p, tmp);
|
memcpy(xauthfile, p, tmp);
|
||||||
xauthfile[tmp] = '\0';
|
xauthfile[tmp] = '\0';
|
||||||
p += tmp;
|
p += tmp;
|
||||||
|
|
||||||
@@ -358,6 +358,8 @@ doit_active (char *host, char *user,
|
|||||||
int tmp2;
|
int tmp2;
|
||||||
char *s;
|
char *s;
|
||||||
int i;
|
int i;
|
||||||
|
size_t rem;
|
||||||
|
u_int32_t other_port;
|
||||||
|
|
||||||
otherside = connect_host (host, user, &key, schedule, port,
|
otherside = connect_host (host, user, &key, schedule, port,
|
||||||
&me, &him);
|
&me, &him);
|
||||||
@@ -372,28 +374,46 @@ doit_active (char *host, char *user,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
p = msg;
|
p = msg;
|
||||||
|
rem = sizeof(msg);
|
||||||
*p++ = INIT;
|
*p++ = INIT;
|
||||||
|
--rem;
|
||||||
len = strlen(user);
|
len = strlen(user);
|
||||||
p += krb_put_int (len, p, 4);
|
tmp = krb_put_int (len, p, rem, 4);
|
||||||
strncpy(p, user, len);
|
if (tmp < 0)
|
||||||
|
return 1;
|
||||||
|
p += tmp;
|
||||||
|
rem -= tmp;
|
||||||
|
memcpy(p, user, len);
|
||||||
p += len;
|
p += len;
|
||||||
|
rem -= len;
|
||||||
*p++ = (keepalivep ? KEEP_ALIVE : 0);
|
*p++ = (keepalivep ? KEEP_ALIVE : 0);
|
||||||
|
--rem;
|
||||||
|
|
||||||
s = getenv("DISPLAY");
|
s = getenv("DISPLAY");
|
||||||
if (s == NULL || (s = strchr(s, ':')) == NULL)
|
if (s == NULL || (s = strchr(s, ':')) == NULL)
|
||||||
s = ":0";
|
s = ":0";
|
||||||
len = strlen (s);
|
len = strlen (s);
|
||||||
p += krb_put_int (len, p, 4);
|
tmp = krb_put_int (len, p, rem, 4);
|
||||||
strncpy (p, s, len);
|
if (tmp < 0)
|
||||||
|
return 1;
|
||||||
|
rem -= tmp;
|
||||||
|
p += tmp;
|
||||||
|
memcpy (p, s, len);
|
||||||
p += len;
|
p += len;
|
||||||
|
rem -= len;
|
||||||
|
|
||||||
s = getenv("XAUTHORITY");
|
s = getenv("XAUTHORITY");
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
s = "";
|
s = "";
|
||||||
len = strlen (s);
|
len = strlen (s);
|
||||||
p += krb_put_int (len, p, 4);
|
tmp = krb_put_int (len, p, rem, 4);
|
||||||
strncpy (p, s, len);
|
if (tmp < 0)
|
||||||
|
return 1;
|
||||||
p += len;
|
p += len;
|
||||||
|
rem -= len;
|
||||||
|
memcpy (p, s, len);
|
||||||
|
p += len;
|
||||||
|
rem -= len;
|
||||||
|
|
||||||
if (write_encrypted (otherside, msg, p - msg, schedule,
|
if (write_encrypted (otherside, msg, p - msg, schedule,
|
||||||
&key, &me, &him) < 0)
|
&key, &me, &him) < 0)
|
||||||
@@ -405,9 +425,11 @@ doit_active (char *host, char *user,
|
|||||||
err (1, "read from %s", host);
|
err (1, "read from %s", host);
|
||||||
p = (u_char *)ret;
|
p = (u_char *)ret;
|
||||||
if (*p == ERROR) {
|
if (*p == ERROR) {
|
||||||
|
u_int32_t u32;
|
||||||
|
|
||||||
p++;
|
p++;
|
||||||
p += krb_get_int (p, &tmp, 4, 0);
|
p += krb_get_int (p, &u32, 4, 0);
|
||||||
errx (1, "%s: %.*s", host, (int)tmp, p);
|
errx (1, "%s: %.*s", host, (int)u32, p);
|
||||||
} else if (*p != ACK) {
|
} else if (*p != ACK) {
|
||||||
errx (1, "%s: strange msg %d", host, *p);
|
errx (1, "%s: strange msg %d", host, *p);
|
||||||
} else
|
} else
|
||||||
@@ -458,14 +480,16 @@ doit_active (char *host, char *user,
|
|||||||
err (1, "read from %s", host);
|
err (1, "read from %s", host);
|
||||||
p = (u_char *)ret;
|
p = (u_char *)ret;
|
||||||
if (*p == ERROR) {
|
if (*p == ERROR) {
|
||||||
|
u_int32_t val;
|
||||||
|
|
||||||
p++;
|
p++;
|
||||||
p += krb_get_int (p, &tmp, 4, 0);
|
p += krb_get_int (p, &val, 4, 0);
|
||||||
errx (1, "%s: %.*s", host, (int)tmp, p);
|
errx (1, "%s: %.*s", host, (int)val, p);
|
||||||
} else if (*p != NEW_CONN) {
|
} else if (*p != NEW_CONN) {
|
||||||
errx (1, "%s: strange msg %d", host, *p);
|
errx (1, "%s: strange msg %d", host, *p);
|
||||||
} else {
|
} else {
|
||||||
p++;
|
p++;
|
||||||
p += krb_get_int (p, &tmp, 4, 0);
|
p += krb_get_int (p, &other_port, 4, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
++nchild;
|
++nchild;
|
||||||
@@ -483,7 +507,7 @@ doit_active (char *host, char *user,
|
|||||||
addr = him;
|
addr = him;
|
||||||
close (otherside);
|
close (otherside);
|
||||||
|
|
||||||
addr.sin_port = htons(tmp);
|
addr.sin_port = htons(other_port);
|
||||||
s = socket (AF_INET, SOCK_STREAM, 0);
|
s = socket (AF_INET, SOCK_STREAM, 0);
|
||||||
if (s < 0)
|
if (s < 0)
|
||||||
err(1, "socket");
|
err(1, "socket");
|
||||||
|
@@ -83,7 +83,7 @@ fatal (int fd, des_cblock *key, des_key_schedule schedule,
|
|||||||
vsnprintf (p + 4, sizeof(msg) - 5, format, args);
|
vsnprintf (p + 4, sizeof(msg) - 5, format, args);
|
||||||
syslog (LOG_ERR, p + 4);
|
syslog (LOG_ERR, p + 4);
|
||||||
len = strlen (p + 4);
|
len = strlen (p + 4);
|
||||||
p += krb_put_int (len, p, 4);
|
p += krb_put_int (len, p, 4, 4);
|
||||||
p += len;
|
p += len;
|
||||||
write_encrypted (fd, msg, p - msg, schedule, key, thisaddr, thataddr);
|
write_encrypted (fd, msg, p - msg, schedule, key, thisaddr, thataddr);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
@@ -113,8 +113,8 @@ recv_conn (int sock, des_cblock *key, des_key_schedule schedule,
|
|||||||
int status;
|
int status;
|
||||||
KTEXT_ST ticket;
|
KTEXT_ST ticket;
|
||||||
AUTH_DAT auth;
|
AUTH_DAT auth;
|
||||||
char user[ANAME_SZ + 1];
|
char user[ANAME_SZ];
|
||||||
char instance[INST_SZ + 1];
|
char instance[INST_SZ];
|
||||||
int addrlen;
|
int addrlen;
|
||||||
char version[KRB_SENDAUTH_VLEN + 1];
|
char version[KRB_SENDAUTH_VLEN + 1];
|
||||||
struct passwd *passwd;
|
struct passwd *passwd;
|
||||||
@@ -177,7 +177,7 @@ recv_conn (int sock, des_cblock *key, des_key_schedule schedule,
|
|||||||
p++;
|
p++;
|
||||||
p += krb_get_int (p, &tmp, 4, 0);
|
p += krb_get_int (p, &tmp, 4, 0);
|
||||||
len = min(sizeof(user), tmp);
|
len = min(sizeof(user), tmp);
|
||||||
strncpy (user, p, len);
|
memcpy (user, p, len);
|
||||||
p += tmp;
|
p += tmp;
|
||||||
user[len] = '\0';
|
user[len] = '\0';
|
||||||
|
|
||||||
@@ -208,12 +208,13 @@ recv_conn (int sock, des_cblock *key, des_key_schedule schedule,
|
|||||||
if (!(flags & PASSIVE)) {
|
if (!(flags & PASSIVE)) {
|
||||||
p += krb_get_int (p, &tmp, 4, 0);
|
p += krb_get_int (p, &tmp, 4, 0);
|
||||||
len = min(tmp, display_size);
|
len = min(tmp, display_size);
|
||||||
strncpy (display, p, len);
|
memcpy (display, p, len);
|
||||||
display[len] = '\0';
|
display[len] = '\0';
|
||||||
p += tmp;
|
p += tmp;
|
||||||
p += krb_get_int (p, &tmp, 4, 0);
|
p += krb_get_int (p, &tmp, 4, 0);
|
||||||
len = min(tmp, xauthfile_size);
|
len = min(tmp, xauthfile_size);
|
||||||
strncpy (xauthfile, p, len);
|
memcpy (xauthfile, p, len);
|
||||||
|
xauthfile[len] = '\0';
|
||||||
p += tmp;
|
p += tmp;
|
||||||
}
|
}
|
||||||
#if defined(SO_KEEPALIVE) && defined(HAVE_SETSOCKOPT)
|
#if defined(SO_KEEPALIVE) && defined(HAVE_SETSOCKOPT)
|
||||||
@@ -301,7 +302,7 @@ doit_conn (int fd, int meta_sock, int flags,
|
|||||||
}
|
}
|
||||||
p = msg;
|
p = msg;
|
||||||
*p++ = NEW_CONN;
|
*p++ = NEW_CONN;
|
||||||
p += krb_put_int (ntohs(addr.sin_port), p, 4);
|
p += krb_put_int (ntohs(addr.sin_port), p, 4, 4);
|
||||||
|
|
||||||
if (write_encrypted (meta_sock, msg, p - msg, schedule, key,
|
if (write_encrypted (meta_sock, msg, p - msg, schedule, key,
|
||||||
thisaddr, thataddr) < 0) {
|
thisaddr, thataddr) < 0) {
|
||||||
@@ -362,6 +363,7 @@ doit(int sock, int tcpp)
|
|||||||
if (flags & PASSIVE) {
|
if (flags & PASSIVE) {
|
||||||
int tmp;
|
int tmp;
|
||||||
int len;
|
int len;
|
||||||
|
size_t rem;
|
||||||
|
|
||||||
tmp = get_xsockets (&nsockets, &sockets, tcpp);
|
tmp = get_xsockets (&nsockets, &sockets, tcpp);
|
||||||
if (tmp < 0) {
|
if (tmp < 0) {
|
||||||
@@ -385,15 +387,37 @@ doit(int sock, int tcpp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
p = msg;
|
p = msg;
|
||||||
|
rem = sizeof(msg);
|
||||||
*p++ = ACK;
|
*p++ = ACK;
|
||||||
|
--rem;
|
||||||
|
|
||||||
len = strlen (display);
|
len = strlen (display);
|
||||||
p += krb_put_int (len, p, 4);
|
tmp = krb_put_int (len, p, rem, 4);
|
||||||
strncpy (p, display, len);
|
if (tmp < 0 || rem < len + 4) {
|
||||||
|
syslog (LOG_ERR, "doit: buffer too small");
|
||||||
|
cleanup(nsockets, sockets);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
p += tmp;
|
||||||
|
rem -= tmp;
|
||||||
|
|
||||||
|
memcpy (p, display, len);
|
||||||
p += len;
|
p += len;
|
||||||
|
rem -= len;
|
||||||
|
|
||||||
len = strlen (xauthfile);
|
len = strlen (xauthfile);
|
||||||
p += krb_put_int (len, p, 4);
|
tmp = krb_put_int (len, p, rem, 4);
|
||||||
strncpy (p, xauthfile, len);
|
if (tmp < 0 || rem < len + 4) {
|
||||||
|
syslog (LOG_ERR, "doit: buffer too small");
|
||||||
|
cleanup(nsockets, sockets);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
p += tmp;
|
||||||
|
rem -= tmp;
|
||||||
|
|
||||||
|
memcpy (p, xauthfile, len);
|
||||||
p += len;
|
p += len;
|
||||||
|
rem -= len;
|
||||||
|
|
||||||
if(write_encrypted (sock, msg, p - msg, schedule, &key,
|
if(write_encrypted (sock, msg, p - msg, schedule, &key,
|
||||||
&me, &him) < 0) {
|
&me, &him) < 0) {
|
||||||
|
@@ -34,4 +34,4 @@ pid=$1
|
|||||||
disp=${2}${screen}
|
disp=${2}${screen}
|
||||||
auth=$3
|
auth=$3
|
||||||
kill -USR1 $pid
|
kill -USR1 $pid
|
||||||
rsh -n $rsh_args $host "env DISPLAY=$disp XAUTHORITY=$auth $term -T $title -n $title $xterm_args &"
|
rsh -n $rsh_args $host "/bin/sh -c 'DISPLAY=$disp XAUTHORITY=$auth $term -T $title -n $title $xterm_args </dev/null >/dev/null 2>/dev/null &'"
|
||||||
|
@@ -92,8 +92,7 @@ renew (int argc, char **argv, OtpAlgorithm *alg, char *user)
|
|||||||
newctx.alg = alg;
|
newctx.alg = alg;
|
||||||
newctx.user = user;
|
newctx.user = user;
|
||||||
newctx.n = atoi (argv[0]);
|
newctx.n = atoi (argv[0]);
|
||||||
strncpy (newctx.seed, argv[1], sizeof(newctx.seed));
|
strcpy_truncate (newctx.seed, argv[1], sizeof(newctx.seed));
|
||||||
newctx.seed[sizeof(newctx.seed) - 1] = '\0';
|
|
||||||
strlwr(newctx.seed);
|
strlwr(newctx.seed);
|
||||||
snprintf (prompt, sizeof(prompt),
|
snprintf (prompt, sizeof(prompt),
|
||||||
"[ otp-%s %u %s ]",
|
"[ otp-%s %u %s ]",
|
||||||
@@ -161,8 +160,7 @@ set (int argc, char **argv, OtpAlgorithm *alg, char *user)
|
|||||||
err (1, "out of memory");
|
err (1, "out of memory");
|
||||||
|
|
||||||
ctx.n = atoi (argv[0]);
|
ctx.n = atoi (argv[0]);
|
||||||
strncpy (ctx.seed, argv[1], sizeof(ctx.seed));
|
strcpy_truncate (ctx.seed, argv[1], sizeof(ctx.seed));
|
||||||
ctx.seed[sizeof(ctx.seed) - 1] = '\0';
|
|
||||||
strlwr(ctx.seed);
|
strlwr(ctx.seed);
|
||||||
do {
|
do {
|
||||||
if (des_read_pw_string (pw, sizeof(pw), "Pass-phrase: ", 1))
|
if (des_read_pw_string (pw, sizeof(pw), "Pass-phrase: ", 1))
|
||||||
|
@@ -35,6 +35,11 @@ Sat Apr 4 15:13:56 1998 Assar Westerlund <assar@sics.se>
|
|||||||
|
|
||||||
* popper.h: include <io.h>
|
* popper.h: include <io.h>
|
||||||
|
|
||||||
|
Sat Feb 7 10:07:39 1998 Assar Westerlund <assar@sics.se>
|
||||||
|
|
||||||
|
* pop_pass.c(krb4_verify_password: Don't use REALM_SZ + 1, just
|
||||||
|
REALM_SZ
|
||||||
|
|
||||||
Mon Dec 29 16:37:26 1997 Assar Westerlund <assar@sics.se>
|
Mon Dec 29 16:37:26 1997 Assar Westerlund <assar@sics.se>
|
||||||
|
|
||||||
* pop_updt.c (pop_updt): lseek before ftruncating the file. From
|
* pop_updt.c (pop_updt): lseek before ftruncating the file. From
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1995, 1996, 1997 Kungliga Tekniska H<>gskolan
|
* Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska H<>gskolan
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -55,7 +55,8 @@ loop(int s)
|
|||||||
err(1, "select");
|
err(1, "select");
|
||||||
if(FD_ISSET(0, &fds)){
|
if(FD_ISSET(0, &fds)){
|
||||||
fgets(cmd, sizeof(cmd), stdin);
|
fgets(cmd, sizeof(cmd), stdin);
|
||||||
strcpy(cmd + strlen(cmd) - 1, "\r\n");
|
cmd[strlen(cmd) - 1] = '\0';
|
||||||
|
strcat_truncate (cmd, "\r\n", sizeof(cmd));
|
||||||
write(s, cmd, strlen(cmd));
|
write(s, cmd, strlen(cmd));
|
||||||
}
|
}
|
||||||
if(FD_ISSET(s, &fds)){
|
if(FD_ISSET(s, &fds)){
|
||||||
|
@@ -73,7 +73,7 @@ pop_dropcopy(POP *p, struct passwd *pwp)
|
|||||||
* running as root.
|
* running as root.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
strcpy(template, POP_TMPDROP);
|
strcpy_truncate(template, POP_TMPDROP, sizeof(template));
|
||||||
if ((tf_fd = mkstemp(template)) < 0 ||
|
if ((tf_fd = mkstemp(template)) < 0 ||
|
||||||
(tf = fdopen(tf_fd, "w+")) == NULL) {
|
(tf = fdopen(tf_fd, "w+")) == NULL) {
|
||||||
pop_log(p,POP_PRIORITY,
|
pop_log(p,POP_PRIORITY,
|
||||||
|
@@ -46,7 +46,7 @@ pop_get_command(POP *p, char *mp)
|
|||||||
|
|
||||||
/* Save a copy of the original client line */
|
/* Save a copy of the original client line */
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if(p->debug) strcpy (buf,mp);
|
if(p->debug) strcpy_truncate (buf, mp, sizeof(buf));
|
||||||
#endif /* DEBUG */
|
#endif /* DEBUG */
|
||||||
|
|
||||||
/* Parse the message into the parameter array */
|
/* Parse the message into the parameter array */
|
||||||
|
@@ -307,8 +307,7 @@ pop_init(POP *p,int argcount,char **argmessage)
|
|||||||
|
|
||||||
/* Save the dotted decimal form of the client's IP address
|
/* Save the dotted decimal form of the client's IP address
|
||||||
in the POP parameter block */
|
in the POP parameter block */
|
||||||
strncpy (p->ipaddr, inet_ntoa(cs.sin_addr), sizeof(p->ipaddr));
|
strcpy_truncate (p->ipaddr, inet_ntoa(cs.sin_addr), sizeof(p->ipaddr));
|
||||||
p->ipaddr[sizeof(p->ipaddr) - 1] = '\0';
|
|
||||||
|
|
||||||
/* Save the client's port */
|
/* Save the client's port */
|
||||||
p->ipport = ntohs(cs.sin_port);
|
p->ipport = ntohs(cs.sin_port);
|
||||||
@@ -320,7 +319,7 @@ pop_init(POP *p,int argcount,char **argmessage)
|
|||||||
if (ch == NULL){
|
if (ch == NULL){
|
||||||
pop_log(p,POP_PRIORITY,
|
pop_log(p,POP_PRIORITY,
|
||||||
"Unable to get canonical name of client, err = %d",errno);
|
"Unable to get canonical name of client, err = %d",errno);
|
||||||
strcpy (p->client, p->ipaddr);
|
strcpy_truncate (p->client, p->ipaddr, sizeof(p->client));
|
||||||
}
|
}
|
||||||
/* Save the cannonical name of the client host in
|
/* Save the cannonical name of the client host in
|
||||||
the POP parameter block */
|
the POP parameter block */
|
||||||
@@ -335,13 +334,12 @@ pop_init(POP *p,int argcount,char **argmessage)
|
|||||||
pop_log(p,POP_PRIORITY,
|
pop_log(p,POP_PRIORITY,
|
||||||
"Client at \"%s\" resolves to an unknown host name \"%s\"",
|
"Client at \"%s\" resolves to an unknown host name \"%s\"",
|
||||||
p->ipaddr,ch->h_name);
|
p->ipaddr,ch->h_name);
|
||||||
strcpy (p->client, p->ipaddr);
|
strcpy_truncate (p->client, p->ipaddr, sizeof(p->client));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Save the host name (the previous value was
|
/* Save the host name (the previous value was
|
||||||
destroyed by gethostbyname) */
|
destroyed by gethostbyname) */
|
||||||
strncpy (p->client, ch_again->h_name, sizeof(p->client));
|
strcpy_truncate (p->client, ch_again->h_name, sizeof(p->client));
|
||||||
p->client[sizeof(p->client) - 1] = '\0';
|
|
||||||
|
|
||||||
/* Look for the client's IP address in the list returned
|
/* Look for the client's IP address in the list returned
|
||||||
for its name */
|
for its name */
|
||||||
@@ -354,7 +352,7 @@ pop_init(POP *p,int argcount,char **argmessage)
|
|||||||
pop_log (p,POP_PRIORITY,
|
pop_log (p,POP_PRIORITY,
|
||||||
"Client address \"%s\" not listed for its host name \"%s\"",
|
"Client address \"%s\" not listed for its host name \"%s\"",
|
||||||
p->ipaddr,ch->h_name);
|
p->ipaddr,ch->h_name);
|
||||||
strcpy (p->client, p->ipaddr);
|
strcpy_truncate (p->client, p->ipaddr, sizeof(p->client));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -46,7 +46,7 @@ pop_msg(POP *p, int stat, char *format, ...)
|
|||||||
pop_log(p,POP_PRIORITY,"%s",message);
|
pop_log(p,POP_PRIORITY,"%s",message);
|
||||||
|
|
||||||
/* Append the <CR><LF> */
|
/* Append the <CR><LF> */
|
||||||
strncat(message, "\r\n", sizeof(message) - strlen(message));
|
strcat_truncate(message, "\r\n", sizeof(message));
|
||||||
|
|
||||||
/* Send the message to the client */
|
/* Send the message to the client */
|
||||||
fputs(message, p->output);
|
fputs(message, p->output);
|
||||||
|
@@ -12,7 +12,7 @@ static int
|
|||||||
krb4_verify_password (POP *p)
|
krb4_verify_password (POP *p)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
char lrealm[REALM_SZ + 1];
|
char lrealm[REALM_SZ];
|
||||||
char tkt[MaxPathLen];
|
char tkt[MaxPathLen];
|
||||||
|
|
||||||
status = krb_get_lrealm(lrealm,1);
|
status = krb_get_lrealm(lrealm,1);
|
||||||
|
@@ -115,10 +115,10 @@ pop_send(POP *p)
|
|||||||
*return_path_end = '\0';
|
*return_path_end = '\0';
|
||||||
if (strlen(return_path_adr) != 0 && *return_path_adr != '\n') {
|
if (strlen(return_path_adr) != 0 && *return_path_adr != '\n') {
|
||||||
static char tmpbuf[MAXMSGLINELEN + 20];
|
static char tmpbuf[MAXMSGLINELEN + 20];
|
||||||
strcpy(tmpbuf, "Return-Path: ");
|
if (snprintf (tmpbuf,
|
||||||
strcat(tmpbuf, return_path_adr);
|
sizeof(tmpbuf),
|
||||||
strcat(tmpbuf, "\n");
|
"Return-Path: %s\n",
|
||||||
if (strlen(tmpbuf) < MAXMSGLINELEN) {
|
return_path_adr) < MAXMSGLINELEN) {
|
||||||
pop_sendline (p,tmpbuf);
|
pop_sendline (p,tmpbuf);
|
||||||
if (hangup)
|
if (hangup)
|
||||||
return pop_msg (p, POP_FAILURE,
|
return pop_msg (p, POP_FAILURE,
|
||||||
|
@@ -16,7 +16,7 @@ pop_user (POP *p)
|
|||||||
{
|
{
|
||||||
char ss[256];
|
char ss[256];
|
||||||
|
|
||||||
strcpy(p->user, p->pop_parm[1]);
|
strcpy_truncate(p->user, p->pop_parm[1], sizeof(p->user));
|
||||||
|
|
||||||
#ifdef OTP
|
#ifdef OTP
|
||||||
if (otp_challenge (&p->otp_ctx, p->user, ss, sizeof(ss)) == 0) {
|
if (otp_challenge (&p->otp_ctx, p->user, ss, sizeof(ss)) == 0) {
|
||||||
|
@@ -20,6 +20,36 @@ Thu Mar 12 02:33:48 1998 Assar Westerlund <assar@sics.se>
|
|||||||
* telnet/telnet_locl.h: include <term.h>. From Gregory S. Stark
|
* telnet/telnet_locl.h: include <term.h>. From Gregory S. Stark
|
||||||
<gsstark@mit.edu>
|
<gsstark@mit.edu>
|
||||||
|
|
||||||
|
Sat Feb 21 15:12:38 1998 Assar Westerlund <assar@sics.se>
|
||||||
|
|
||||||
|
* telnetd/ext.h: add prototype for login_tty
|
||||||
|
|
||||||
|
* telnet/utilities.c (printsub): `direction' is now an int.
|
||||||
|
|
||||||
|
* libtelnet/misc-proto.h: add prototype for `printsub'
|
||||||
|
|
||||||
|
Tue Feb 17 02:45:01 1998 Assar Westerlund <assar@sics.se>
|
||||||
|
|
||||||
|
* libtelnet/kerberos.c (kerberos4_is): cred.pname should be
|
||||||
|
cred.pinst. From <art@stacken.kth.se>
|
||||||
|
|
||||||
|
Sun Feb 15 02:46:39 1998 Assar Westerlund <assar@sics.se>
|
||||||
|
|
||||||
|
* telnet/*/*.c: renamed `telnet' to `my_telnet' to avoid
|
||||||
|
conflicts with system header files on mklinux.
|
||||||
|
|
||||||
|
Tue Feb 10 02:09:03 1998 Assar Westerlund <assar@sics.se>
|
||||||
|
|
||||||
|
* telnetd/telnetd.c: new signature for `getterminaltype' and
|
||||||
|
`auth_wait'
|
||||||
|
|
||||||
|
* libtelnet: changed the signature of the authentication method
|
||||||
|
`status'
|
||||||
|
|
||||||
|
Sat Feb 7 07:21:29 1998 Assar Westerlund <assar@sics.se>
|
||||||
|
|
||||||
|
* */*.c: replace HAS_GETTOS by HAVE_PARSETOS and HAVE_GETTOSBYNAME
|
||||||
|
|
||||||
Fri Dec 26 16:17:10 1997 Assar Westerlund <assar@sics.se>
|
Fri Dec 26 16:17:10 1997 Assar Westerlund <assar@sics.se>
|
||||||
|
|
||||||
* telnet/commands.c (tn): repair support for numeric addresses
|
* telnet/commands.c (tn): repair support for numeric addresses
|
||||||
|
@@ -58,7 +58,7 @@
|
|||||||
#ifdef AUTHENTICATION
|
#ifdef AUTHENTICATION
|
||||||
Authenticator *findauthenticator (int, int);
|
Authenticator *findauthenticator (int, int);
|
||||||
|
|
||||||
int auth_wait (char *);
|
int auth_wait (char *, size_t);
|
||||||
void auth_disable_name (char *);
|
void auth_disable_name (char *);
|
||||||
void auth_finished (Authenticator *, int);
|
void auth_finished (Authenticator *, int);
|
||||||
void auth_gen_printsub (unsigned char *, int, unsigned char *, int);
|
void auth_gen_printsub (unsigned char *, int, unsigned char *, int);
|
||||||
@@ -105,7 +105,7 @@ int kerberos4_send_mutual (Authenticator *);
|
|||||||
int kerberos4_send_oneway (Authenticator *);
|
int kerberos4_send_oneway (Authenticator *);
|
||||||
void kerberos4_is (Authenticator *, unsigned char *, int);
|
void kerberos4_is (Authenticator *, unsigned char *, int);
|
||||||
void kerberos4_reply (Authenticator *, unsigned char *, int);
|
void kerberos4_reply (Authenticator *, unsigned char *, int);
|
||||||
int kerberos4_status (Authenticator *, char *, int);
|
int kerberos4_status (Authenticator *, char *, size_t, int);
|
||||||
void kerberos4_printsub (unsigned char *, int, unsigned char *, int);
|
void kerberos4_printsub (unsigned char *, int, unsigned char *, int);
|
||||||
int kerberos4_forward(Authenticator *ap, void *);
|
int kerberos4_forward(Authenticator *ap, void *);
|
||||||
#endif
|
#endif
|
||||||
@@ -116,7 +116,7 @@ int kerberos5_send_mutual (Authenticator *);
|
|||||||
int kerberos5_send_oneway (Authenticator *);
|
int kerberos5_send_oneway (Authenticator *);
|
||||||
void kerberos5_is (Authenticator *, unsigned char *, int);
|
void kerberos5_is (Authenticator *, unsigned char *, int);
|
||||||
void kerberos5_reply (Authenticator *, unsigned char *, int);
|
void kerberos5_reply (Authenticator *, unsigned char *, int);
|
||||||
int kerberos5_status (Authenticator *, char *, int);
|
int kerberos5_status (Authenticator *, char *, size_t, int);
|
||||||
void kerberos5_printsub (unsigned char *, int, unsigned char *, int);
|
void kerberos5_printsub (unsigned char *, int, unsigned char *, int);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@@ -584,7 +584,7 @@ auth_intr(int sig)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
auth_wait(char *name)
|
auth_wait(char *name, size_t name_sz)
|
||||||
{
|
{
|
||||||
if (auth_debug_mode)
|
if (auth_debug_mode)
|
||||||
printf(">>>%s: in auth_wait.\r\n", Name);
|
printf(">>>%s: in auth_wait.\r\n", Name);
|
||||||
@@ -611,7 +611,8 @@ auth_wait(char *name)
|
|||||||
|
|
||||||
if (authenticated->status)
|
if (authenticated->status)
|
||||||
validuser = (*authenticated->status)(authenticated,
|
validuser = (*authenticated->status)(authenticated,
|
||||||
name, validuser);
|
name, name_sz,
|
||||||
|
validuser);
|
||||||
return(validuser);
|
return(validuser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -71,7 +71,7 @@ typedef struct XauthP {
|
|||||||
int (*send) (struct XauthP *);
|
int (*send) (struct XauthP *);
|
||||||
void (*is) (struct XauthP *, unsigned char *, int);
|
void (*is) (struct XauthP *, unsigned char *, int);
|
||||||
void (*reply) (struct XauthP *, unsigned char *, int);
|
void (*reply) (struct XauthP *, unsigned char *, int);
|
||||||
int (*status) (struct XauthP *, char *, int);
|
int (*status) (struct XauthP *, char *, size_t, int);
|
||||||
void (*printsub) (unsigned char *, int, unsigned char *, int);
|
void (*printsub) (unsigned char *, int, unsigned char *, int);
|
||||||
} Authenticator;
|
} Authenticator;
|
||||||
|
|
||||||
|
@@ -180,10 +180,9 @@ kerberos4_send(char *name, Authenticator *ap)
|
|||||||
|
|
||||||
memset(instance, 0, sizeof(instance));
|
memset(instance, 0, sizeof(instance));
|
||||||
|
|
||||||
if ((realm = krb_get_phost(RemoteHostName)))
|
strcpy_truncate (instance,
|
||||||
strncpy(instance, realm, sizeof(instance));
|
krb_get_phost(RemoteHostName),
|
||||||
|
INST_SZ);
|
||||||
instance[sizeof(instance)-1] = '\0';
|
|
||||||
|
|
||||||
realm = dest_realm ? dest_realm : krb_realmofhost(RemoteHostName);
|
realm = dest_realm ? dest_realm : krb_realmofhost(RemoteHostName);
|
||||||
|
|
||||||
@@ -410,7 +409,7 @@ kerberos4_is(Authenticator *ap, unsigned char *data, int cnt)
|
|||||||
cred.issue_date < 0 ||
|
cred.issue_date < 0 ||
|
||||||
cred.issue_date > time(0) + CLOCK_SKEW ||
|
cred.issue_date > time(0) + CLOCK_SKEW ||
|
||||||
strncmp(cred.pname, adat.pname, sizeof(cred.pname)) ||
|
strncmp(cred.pname, adat.pname, sizeof(cred.pname)) ||
|
||||||
strncmp(cred.pinst, adat.pinst, sizeof(cred.pname))){
|
strncmp(cred.pinst, adat.pinst, sizeof(cred.pinst))){
|
||||||
Data(ap, KRB_FORWARD_REJECT, "Bad credentials", -1);
|
Data(ap, KRB_FORWARD_REJECT, "Bad credentials", -1);
|
||||||
}else{
|
}else{
|
||||||
if((ret = tf_setup(&cred,
|
if((ret = tf_setup(&cred,
|
||||||
@@ -508,13 +507,13 @@ kerberos4_reply(Authenticator *ap, unsigned char *data, int cnt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
kerberos4_status(Authenticator *ap, char *name, int level)
|
kerberos4_status(Authenticator *ap, char *name, size_t name_sz, int level)
|
||||||
{
|
{
|
||||||
if (level < AUTH_USER)
|
if (level < AUTH_USER)
|
||||||
return(level);
|
return(level);
|
||||||
|
|
||||||
if (UserNameRequested && !kuserok(&adat, UserNameRequested)) {
|
if (UserNameRequested && !kuserok(&adat, UserNameRequested)) {
|
||||||
strcpy(name, UserNameRequested);
|
strcpy_truncate(name, UserNameRequested, name_sz);
|
||||||
return(AUTH_VALID);
|
return(AUTH_VALID);
|
||||||
} else
|
} else
|
||||||
return(AUTH_USER);
|
return(AUTH_USER);
|
||||||
@@ -526,7 +525,6 @@ kerberos4_status(Authenticator *ap, char *name, int level)
|
|||||||
void
|
void
|
||||||
kerberos4_printsub(unsigned char *data, int cnt, unsigned char *buf, int buflen)
|
kerberos4_printsub(unsigned char *data, int cnt, unsigned char *buf, int buflen)
|
||||||
{
|
{
|
||||||
char lbuf[32];
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
buf[buflen-1] = '\0'; /* make sure its NULL terminated */
|
buf[buflen-1] = '\0'; /* make sure its NULL terminated */
|
||||||
@@ -534,11 +532,11 @@ kerberos4_printsub(unsigned char *data, int cnt, unsigned char *buf, int buflen)
|
|||||||
|
|
||||||
switch(data[3]) {
|
switch(data[3]) {
|
||||||
case KRB_REJECT: /* Rejected (reason might follow) */
|
case KRB_REJECT: /* Rejected (reason might follow) */
|
||||||
strncpy((char *)buf, " REJECT ", buflen);
|
strcpy_truncate((char *)buf, " REJECT ", buflen);
|
||||||
goto common;
|
goto common;
|
||||||
|
|
||||||
case KRB_ACCEPT: /* Accepted (name might follow) */
|
case KRB_ACCEPT: /* Accepted (name might follow) */
|
||||||
strncpy((char *)buf, " ACCEPT ", buflen);
|
strcpy_truncate((char *)buf, " ACCEPT ", buflen);
|
||||||
common:
|
common:
|
||||||
BUMP(buf, buflen);
|
BUMP(buf, buflen);
|
||||||
if (cnt <= 4)
|
if (cnt <= 4)
|
||||||
@@ -551,25 +549,23 @@ kerberos4_printsub(unsigned char *data, int cnt, unsigned char *buf, int buflen)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case KRB_AUTH: /* Authentication data follows */
|
case KRB_AUTH: /* Authentication data follows */
|
||||||
strncpy((char *)buf, " AUTH", buflen);
|
strcpy_truncate((char *)buf, " AUTH", buflen);
|
||||||
goto common2;
|
goto common2;
|
||||||
|
|
||||||
case KRB_CHALLENGE:
|
case KRB_CHALLENGE:
|
||||||
strncpy((char *)buf, " CHALLENGE", buflen);
|
strcpy_truncate((char *)buf, " CHALLENGE", buflen);
|
||||||
goto common2;
|
goto common2;
|
||||||
|
|
||||||
case KRB_RESPONSE:
|
case KRB_RESPONSE:
|
||||||
strncpy((char *)buf, " RESPONSE", buflen);
|
strcpy_truncate((char *)buf, " RESPONSE", buflen);
|
||||||
goto common2;
|
goto common2;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
snprintf(lbuf, sizeof(lbuf), " %d (unknown)", data[3]);
|
snprintf(buf, buflen, " %d (unknown)", data[3]);
|
||||||
strncpy((char *)buf, lbuf, buflen);
|
|
||||||
common2:
|
common2:
|
||||||
BUMP(buf, buflen);
|
BUMP(buf, buflen);
|
||||||
for (i = 4; i < cnt; i++) {
|
for (i = 4; i < cnt; i++) {
|
||||||
snprintf(lbuf, sizeof(lbuf), " %d", data[i]);
|
snprintf(buf, buflen, " %d", data[i]);
|
||||||
strncpy((char *)buf, lbuf, buflen);
|
|
||||||
BUMP(buf, buflen);
|
BUMP(buf, buflen);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -624,13 +620,13 @@ pack_cred(CREDENTIALS *cred, unsigned char *buf)
|
|||||||
p += REALM_SZ;
|
p += REALM_SZ;
|
||||||
memcpy(p, cred->session, 8);
|
memcpy(p, cred->session, 8);
|
||||||
p += 8;
|
p += 8;
|
||||||
p += krb_put_int(cred->lifetime, p, 4);
|
p += krb_put_int(cred->lifetime, p, 4, 4);
|
||||||
p += krb_put_int(cred->kvno, p, 4);
|
p += krb_put_int(cred->kvno, p, 4, 4);
|
||||||
p += krb_put_int(cred->ticket_st.length, p, 4);
|
p += krb_put_int(cred->ticket_st.length, p, 4, 4);
|
||||||
memcpy(p, cred->ticket_st.dat, cred->ticket_st.length);
|
memcpy(p, cred->ticket_st.dat, cred->ticket_st.length);
|
||||||
p += cred->ticket_st.length;
|
p += cred->ticket_st.length;
|
||||||
p += krb_put_int(0, p, 4);
|
p += krb_put_int(0, p, 4, 4);
|
||||||
p += krb_put_int(cred->issue_date, p, 4);
|
p += krb_put_int(cred->issue_date, p, 4, 4);
|
||||||
memcpy (p, cred->pname, ANAME_SZ);
|
memcpy (p, cred->pname, ANAME_SZ);
|
||||||
p += ANAME_SZ;
|
p += ANAME_SZ;
|
||||||
memcpy (p, cred->pinst, INST_SZ);
|
memcpy (p, cred->pinst, INST_SZ);
|
||||||
|
@@ -608,7 +608,7 @@ kerberos5_reply(Authenticator *ap, unsigned char *data, int cnt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
kerberos5_status(Authenticator *ap, char *name, int level)
|
kerberos5_status(Authenticator *ap, char *name, size_t name_sz, int level)
|
||||||
{
|
{
|
||||||
if (level < AUTH_USER)
|
if (level < AUTH_USER)
|
||||||
return(level);
|
return(level);
|
||||||
@@ -618,7 +618,7 @@ kerberos5_status(Authenticator *ap, char *name, int level)
|
|||||||
ticket->client,
|
ticket->client,
|
||||||
UserNameRequested))
|
UserNameRequested))
|
||||||
{
|
{
|
||||||
strcpy(name, UserNameRequested);
|
strcpy_truncate(name, UserNameRequested, name_sz);
|
||||||
return(AUTH_VALID);
|
return(AUTH_VALID);
|
||||||
} else
|
} else
|
||||||
return(AUTH_USER);
|
return(AUTH_USER);
|
||||||
@@ -630,7 +630,6 @@ kerberos5_status(Authenticator *ap, char *name, int level)
|
|||||||
void
|
void
|
||||||
kerberos5_printsub(unsigned char *data, int cnt, unsigned char *buf, int buflen)
|
kerberos5_printsub(unsigned char *data, int cnt, unsigned char *buf, int buflen)
|
||||||
{
|
{
|
||||||
char lbuf[32];
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
buf[buflen-1] = '\0'; /* make sure its NULL terminated */
|
buf[buflen-1] = '\0'; /* make sure its NULL terminated */
|
||||||
@@ -638,11 +637,11 @@ kerberos5_printsub(unsigned char *data, int cnt, unsigned char *buf, int buflen)
|
|||||||
|
|
||||||
switch(data[3]) {
|
switch(data[3]) {
|
||||||
case KRB_REJECT: /* Rejected (reason might follow) */
|
case KRB_REJECT: /* Rejected (reason might follow) */
|
||||||
strncpy((char *)buf, " REJECT ", buflen);
|
strcpy_truncate((char *)buf, " REJECT ", buflen);
|
||||||
goto common;
|
goto common;
|
||||||
|
|
||||||
case KRB_ACCEPT: /* Accepted (name might follow) */
|
case KRB_ACCEPT: /* Accepted (name might follow) */
|
||||||
strncpy((char *)buf, " ACCEPT ", buflen);
|
strcpy_truncate((char *)buf, " ACCEPT ", buflen);
|
||||||
common:
|
common:
|
||||||
BUMP(buf, buflen);
|
BUMP(buf, buflen);
|
||||||
if (cnt <= 4)
|
if (cnt <= 4)
|
||||||
@@ -656,36 +655,34 @@ kerberos5_printsub(unsigned char *data, int cnt, unsigned char *buf, int buflen)
|
|||||||
|
|
||||||
|
|
||||||
case KRB_AUTH: /* Authentication data follows */
|
case KRB_AUTH: /* Authentication data follows */
|
||||||
strncpy((char *)buf, " AUTH", buflen);
|
strcpy_truncate((char *)buf, " AUTH", buflen);
|
||||||
goto common2;
|
goto common2;
|
||||||
|
|
||||||
case KRB_RESPONSE:
|
case KRB_RESPONSE:
|
||||||
strncpy((char *)buf, " RESPONSE", buflen);
|
strcpy_truncate((char *)buf, " RESPONSE", buflen);
|
||||||
goto common2;
|
goto common2;
|
||||||
|
|
||||||
#ifdef FORWARD
|
#ifdef FORWARD
|
||||||
case KRB_FORWARD: /* Forwarded credentials follow */
|
case KRB_FORWARD: /* Forwarded credentials follow */
|
||||||
strncpy((char *)buf, " FORWARD", buflen);
|
strcpy_truncate((char *)buf, " FORWARD", buflen);
|
||||||
goto common2;
|
goto common2;
|
||||||
|
|
||||||
case KRB_FORWARD_ACCEPT: /* Forwarded credentials accepted */
|
case KRB_FORWARD_ACCEPT: /* Forwarded credentials accepted */
|
||||||
strncpy((char *)buf, " FORWARD_ACCEPT", buflen);
|
strcpy_truncate((char *)buf, " FORWARD_ACCEPT", buflen);
|
||||||
goto common2;
|
goto common2;
|
||||||
|
|
||||||
case KRB_FORWARD_REJECT: /* Forwarded credentials rejected */
|
case KRB_FORWARD_REJECT: /* Forwarded credentials rejected */
|
||||||
/* (reason might follow) */
|
/* (reason might follow) */
|
||||||
strncpy((char *)buf, " FORWARD_REJECT", buflen);
|
strcpy_truncate((char *)buf, " FORWARD_REJECT", buflen);
|
||||||
goto common2;
|
goto common2;
|
||||||
#endif /* FORWARD */
|
#endif /* FORWARD */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
snprintf(lbuf, sizeof(lbuf), " %d (unknown)", data[3]);
|
snprintf(buf, buflen, " %d (unknown)", data[3]);
|
||||||
strncpy((char *)buf, lbuf, buflen);
|
|
||||||
common2:
|
common2:
|
||||||
BUMP(buf, buflen);
|
BUMP(buf, buflen);
|
||||||
for (i = 4; i < cnt; i++) {
|
for (i = 4; i < cnt; i++) {
|
||||||
snprintf(lbuf, sizeof(lbuf), " %d", data[i]);
|
snprintf(buf, buflen, " %d", data[i]);
|
||||||
strncpy((char *)buf, lbuf, buflen);
|
|
||||||
BUMP(buf, buflen);
|
BUMP(buf, buflen);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@@ -308,7 +308,7 @@ krb4encpwd_reply(ap, data, cnt)
|
|||||||
des_read_pw_string(user_passwd, sizeof(user_passwd)-1, "Password: ", 0);
|
des_read_pw_string(user_passwd, sizeof(user_passwd)-1, "Password: ", 0);
|
||||||
UserPassword = user_passwd;
|
UserPassword = user_passwd;
|
||||||
Challenge = challenge;
|
Challenge = challenge;
|
||||||
strcpy(instance, RemoteHostName);
|
strcpy_truncate(instance, RemoteHostName, sizeof(instance));
|
||||||
if ((cp = strchr(instance, '.')) != 0) *cp = '\0';
|
if ((cp = strchr(instance, '.')) != 0) *cp = '\0';
|
||||||
|
|
||||||
if (r = krb_mk_encpwd_req(&krb_token, KRB_SERVICE_NAME, instance, realm, Challenge, UserNameRequested, user_passwd)) {
|
if (r = krb_mk_encpwd_req(&krb_token, KRB_SERVICE_NAME, instance, realm, Challenge, UserNameRequested, user_passwd)) {
|
||||||
@@ -327,9 +327,10 @@ krb4encpwd_reply(ap, data, cnt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
krb4encpwd_status(ap, name, level)
|
krb4encpwd_status(ap, name, name_sz, level)
|
||||||
Authenticator *ap;
|
Authenticator *ap;
|
||||||
char *name;
|
char *name;
|
||||||
|
size_t name_sz;
|
||||||
int level;
|
int level;
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -337,7 +338,7 @@ krb4encpwd_status(ap, name, level)
|
|||||||
return(level);
|
return(level);
|
||||||
|
|
||||||
if (UserNameRequested && passwdok(UserNameRequested, UserPassword)) {
|
if (UserNameRequested && passwdok(UserNameRequested, UserPassword)) {
|
||||||
strcpy(name, UserNameRequested);
|
strcpy_truncate(name, UserNameRequested, name_sz);
|
||||||
return(AUTH_VALID);
|
return(AUTH_VALID);
|
||||||
} else {
|
} else {
|
||||||
return(AUTH_USER);
|
return(AUTH_USER);
|
||||||
@@ -352,7 +353,6 @@ krb4encpwd_printsub(data, cnt, buf, buflen)
|
|||||||
unsigned char *data, *buf;
|
unsigned char *data, *buf;
|
||||||
int cnt, buflen;
|
int cnt, buflen;
|
||||||
{
|
{
|
||||||
char lbuf[32];
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
buf[buflen-1] = '\0'; /* make sure its NULL terminated */
|
buf[buflen-1] = '\0'; /* make sure its NULL terminated */
|
||||||
@@ -360,11 +360,11 @@ krb4encpwd_printsub(data, cnt, buf, buflen)
|
|||||||
|
|
||||||
switch(data[3]) {
|
switch(data[3]) {
|
||||||
case KRB4_ENCPWD_REJECT: /* Rejected (reason might follow) */
|
case KRB4_ENCPWD_REJECT: /* Rejected (reason might follow) */
|
||||||
strncpy((char *)buf, " REJECT ", buflen);
|
strcpy_truncate((char *)buf, " REJECT ", buflen);
|
||||||
goto common;
|
goto common;
|
||||||
|
|
||||||
case KRB4_ENCPWD_ACCEPT: /* Accepted (name might follow) */
|
case KRB4_ENCPWD_ACCEPT: /* Accepted (name might follow) */
|
||||||
strncpy((char *)buf, " ACCEPT ", buflen);
|
strcpy_truncate((char *)buf, " ACCEPT ", buflen);
|
||||||
common:
|
common:
|
||||||
BUMP(buf, buflen);
|
BUMP(buf, buflen);
|
||||||
if (cnt <= 4)
|
if (cnt <= 4)
|
||||||
@@ -377,25 +377,23 @@ krb4encpwd_printsub(data, cnt, buf, buflen)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case KRB4_ENCPWD_AUTH: /* Authentication data follows */
|
case KRB4_ENCPWD_AUTH: /* Authentication data follows */
|
||||||
strncpy((char *)buf, " AUTH", buflen);
|
strcpy_truncate((char *)buf, " AUTH", buflen);
|
||||||
goto common2;
|
goto common2;
|
||||||
|
|
||||||
case KRB4_ENCPWD_CHALLENGE:
|
case KRB4_ENCPWD_CHALLENGE:
|
||||||
strncpy((char *)buf, " CHALLENGE", buflen);
|
strcpy_truncate((char *)buf, " CHALLENGE", buflen);
|
||||||
goto common2;
|
goto common2;
|
||||||
|
|
||||||
case KRB4_ENCPWD_ACK:
|
case KRB4_ENCPWD_ACK:
|
||||||
strncpy((char *)buf, " ACK", buflen);
|
strcpy_truncate((char *)buf, " ACK", buflen);
|
||||||
goto common2;
|
goto common2;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
snprintf(lbuf, sizeof(lbuf), " %d (unknown)", data[3]);
|
snprintf(buf, buflen, " %d (unknown)", data[3]);
|
||||||
strncpy((char *)buf, lbuf, buflen);
|
|
||||||
common2:
|
common2:
|
||||||
BUMP(buf, buflen);
|
BUMP(buf, buflen);
|
||||||
for (i = 4; i < cnt; i++) {
|
for (i = 4; i < cnt; i++) {
|
||||||
snprintf(lbuf, sizeof(lbuf), " %d", data[i]);
|
snprintf(buf, buflen, " %d", data[i]);
|
||||||
strncpy((char *)buf, lbuf, buflen);
|
|
||||||
BUMP(buf, buflen);
|
BUMP(buf, buflen);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@@ -75,4 +75,5 @@ void net_encrypt (void);
|
|||||||
int telnet_spin (void);
|
int telnet_spin (void);
|
||||||
char *telnet_getenv (char *);
|
char *telnet_getenv (char *);
|
||||||
char *telnet_gets (char *, char *, int, int);
|
char *telnet_gets (char *, char *, int, int);
|
||||||
|
void printsub(int direction, unsigned char *pointer, int length);
|
||||||
#endif
|
#endif
|
||||||
|
@@ -35,14 +35,15 @@
|
|||||||
|
|
||||||
RCSID("$Id$");
|
RCSID("$Id$");
|
||||||
|
|
||||||
#include "misc.h"
|
|
||||||
#include "auth.h"
|
|
||||||
#include "encrypt.h"
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#ifdef SOCKS
|
#ifdef SOCKS
|
||||||
#include <socks.h>
|
#include <socks.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include "misc.h"
|
||||||
|
#include "auth.h"
|
||||||
|
#include "encrypt.h"
|
||||||
|
|
||||||
#include <roken.h>
|
#include <roken.h>
|
||||||
|
|
||||||
|
@@ -159,9 +159,8 @@ rsaencpwd_init(ap, server)
|
|||||||
memset(key_file, 0, sizeof(key_file));
|
memset(key_file, 0, sizeof(key_file));
|
||||||
gethostname(lhostname, sizeof(lhostname));
|
gethostname(lhostname, sizeof(lhostname));
|
||||||
if ((cp = strchr(lhostname, '.')) != 0) *cp = '\0';
|
if ((cp = strchr(lhostname, '.')) != 0) *cp = '\0';
|
||||||
strcpy(key_file, "/etc/.");
|
snprintf(key_file, sizeof(key_file),
|
||||||
strcat(key_file, lhostname);
|
"/etc/.%s_privkey", lhostname);
|
||||||
strcat(key_file, "_privkey");
|
|
||||||
if ((fp=fopen(key_file, "r"))==NULL) return(0);
|
if ((fp=fopen(key_file, "r"))==NULL) return(0);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
} else {
|
} else {
|
||||||
@@ -261,7 +260,7 @@ rsaencpwd_is(ap, data, cnt)
|
|||||||
snprintf(challenge, sizeof(challenge), "%x", now);
|
snprintf(challenge, sizeof(challenge), "%x", now);
|
||||||
challenge_len = strlen(challenge);
|
challenge_len = strlen(challenge);
|
||||||
} else {
|
} else {
|
||||||
strcpy(challenge, "randchal");
|
strcpy_truncate(challenge, "randchal", sizeof(challenge));
|
||||||
challenge_len = 8;
|
challenge_len = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -382,9 +381,10 @@ rsaencpwd_reply(ap, data, cnt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
rsaencpwd_status(ap, name, level)
|
rsaencpwd_status(ap, name, name_sz, level)
|
||||||
Authenticator *ap;
|
Authenticator *ap;
|
||||||
char *name;
|
char *name;
|
||||||
|
size_t name_sz;
|
||||||
int level;
|
int level;
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -392,7 +392,7 @@ rsaencpwd_status(ap, name, level)
|
|||||||
return(level);
|
return(level);
|
||||||
|
|
||||||
if (UserNameRequested && rsaencpwd_passwdok(UserNameRequested, UserPassword)) {
|
if (UserNameRequested && rsaencpwd_passwdok(UserNameRequested, UserPassword)) {
|
||||||
strcpy(name, UserNameRequested);
|
strcpy_truncate(name, UserNameRequested, name_sz);
|
||||||
return(AUTH_VALID);
|
return(AUTH_VALID);
|
||||||
} else {
|
} else {
|
||||||
return(AUTH_USER);
|
return(AUTH_USER);
|
||||||
@@ -407,7 +407,6 @@ rsaencpwd_printsub(data, cnt, buf, buflen)
|
|||||||
unsigned char *data, *buf;
|
unsigned char *data, *buf;
|
||||||
int cnt, buflen;
|
int cnt, buflen;
|
||||||
{
|
{
|
||||||
char lbuf[32];
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
buf[buflen-1] = '\0'; /* make sure its NULL terminated */
|
buf[buflen-1] = '\0'; /* make sure its NULL terminated */
|
||||||
@@ -415,11 +414,11 @@ rsaencpwd_printsub(data, cnt, buf, buflen)
|
|||||||
|
|
||||||
switch(data[3]) {
|
switch(data[3]) {
|
||||||
case RSA_ENCPWD_REJECT: /* Rejected (reason might follow) */
|
case RSA_ENCPWD_REJECT: /* Rejected (reason might follow) */
|
||||||
strncpy((char *)buf, " REJECT ", buflen);
|
strcpy_truncate((char *)buf, " REJECT ", buflen);
|
||||||
goto common;
|
goto common;
|
||||||
|
|
||||||
case RSA_ENCPWD_ACCEPT: /* Accepted (name might follow) */
|
case RSA_ENCPWD_ACCEPT: /* Accepted (name might follow) */
|
||||||
strncpy((char *)buf, " ACCEPT ", buflen);
|
strcpy_truncate((char *)buf, " ACCEPT ", buflen);
|
||||||
common:
|
common:
|
||||||
BUMP(buf, buflen);
|
BUMP(buf, buflen);
|
||||||
if (cnt <= 4)
|
if (cnt <= 4)
|
||||||
@@ -432,21 +431,19 @@ rsaencpwd_printsub(data, cnt, buf, buflen)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case RSA_ENCPWD_AUTH: /* Authentication data follows */
|
case RSA_ENCPWD_AUTH: /* Authentication data follows */
|
||||||
strncpy((char *)buf, " AUTH", buflen);
|
strcpy_truncate((char *)buf, " AUTH", buflen);
|
||||||
goto common2;
|
goto common2;
|
||||||
|
|
||||||
case RSA_ENCPWD_CHALLENGEKEY:
|
case RSA_ENCPWD_CHALLENGEKEY:
|
||||||
strncpy((char *)buf, " CHALLENGEKEY", buflen);
|
strcpy_truncate((char *)buf, " CHALLENGEKEY", buflen);
|
||||||
goto common2;
|
goto common2;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
snprintf(lbuf, sizeof(lbuf), " %d (unknown)", data[3]);
|
snprintf(buf, buflen, " %d (unknown)", data[3]);
|
||||||
strncpy((char *)buf, lbuf, buflen);
|
|
||||||
common2:
|
common2:
|
||||||
BUMP(buf, buflen);
|
BUMP(buf, buflen);
|
||||||
for (i = 4; i < cnt; i++) {
|
for (i = 4; i < cnt; i++) {
|
||||||
snprintf(lbuf, sizeof(lbuf), " %d", data[i]);
|
snprintf(buf, buflen, " %d", data[i]);
|
||||||
strncpy((char *)buf, lbuf, buflen);
|
|
||||||
BUMP(buf, buflen);
|
BUMP(buf, buflen);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@@ -173,8 +173,8 @@ spx_init(ap, server)
|
|||||||
if (server) {
|
if (server) {
|
||||||
str_data[3] = TELQUAL_REPLY;
|
str_data[3] = TELQUAL_REPLY;
|
||||||
gethostname(lhostname, sizeof(lhostname));
|
gethostname(lhostname, sizeof(lhostname));
|
||||||
strcpy(targ_printable, "SERVICE:rcmd@");
|
snprintf (targ_printable, sizeof(targ_printable),
|
||||||
strcat(targ_printable, lhostname);
|
"SERVICE:rcmd@%s", lhostname);
|
||||||
input_name_buffer.length = strlen(targ_printable);
|
input_name_buffer.length = strlen(targ_printable);
|
||||||
input_name_buffer.value = targ_printable;
|
input_name_buffer.value = targ_printable;
|
||||||
major_status = gss_import_name(&status,
|
major_status = gss_import_name(&status,
|
||||||
@@ -216,8 +216,8 @@ spx_send(ap)
|
|||||||
char *address;
|
char *address;
|
||||||
|
|
||||||
printf("[ Trying SPX ... ]\r\n");
|
printf("[ Trying SPX ... ]\r\n");
|
||||||
strcpy(targ_printable, "SERVICE:rcmd@");
|
snprintf (targ_printable, sizeof(targ_printable),
|
||||||
strcat(targ_printable, RemoteHostName);
|
"SERVICE:rcmd@%s", RemoteHostName);
|
||||||
|
|
||||||
input_name_buffer.length = strlen(targ_printable);
|
input_name_buffer.length = strlen(targ_printable);
|
||||||
input_name_buffer.value = targ_printable;
|
input_name_buffer.value = targ_printable;
|
||||||
@@ -324,8 +324,8 @@ spx_is(ap, data, cnt)
|
|||||||
|
|
||||||
gethostname(lhostname, sizeof(lhostname));
|
gethostname(lhostname, sizeof(lhostname));
|
||||||
|
|
||||||
strcpy(targ_printable, "SERVICE:rcmd@");
|
snprintf(targ_printable, sizeof(targ_printable),
|
||||||
strcat(targ_printable, lhostname);
|
"SERVICE:rcmd@%s", lhostname);
|
||||||
|
|
||||||
input_name_buffer.length = strlen(targ_printable);
|
input_name_buffer.length = strlen(targ_printable);
|
||||||
input_name_buffer.value = targ_printable;
|
input_name_buffer.value = targ_printable;
|
||||||
@@ -472,9 +472,10 @@ spx_reply(ap, data, cnt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
spx_status(ap, name, level)
|
spx_status(ap, name, name_sz, level)
|
||||||
Authenticator *ap;
|
Authenticator *ap;
|
||||||
char *name;
|
char *name;
|
||||||
|
size_t name_sz;
|
||||||
int level;
|
int level;
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -495,8 +496,9 @@ spx_status(ap, name, level)
|
|||||||
return(AUTH_USER); /* not authenticated */
|
return(AUTH_USER); /* not authenticated */
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(acl_file, pwd->pw_dir);
|
snprintf (acl_file, sizeof(acl_file),
|
||||||
strcat(acl_file, "/.sphinx");
|
"%s/.sphinx", pwd->pw_dir);
|
||||||
|
|
||||||
acl_file_buffer.value = acl_file;
|
acl_file_buffer.value = acl_file;
|
||||||
acl_file_buffer.length = strlen(acl_file);
|
acl_file_buffer.length = strlen(acl_file);
|
||||||
|
|
||||||
@@ -512,7 +514,7 @@ spx_status(ap, name, level)
|
|||||||
&acl_file_buffer);
|
&acl_file_buffer);
|
||||||
|
|
||||||
if (major_status == GSS_S_COMPLETE) {
|
if (major_status == GSS_S_COMPLETE) {
|
||||||
strcpy(name, UserNameRequested);
|
strcpy_truncate(name, UserNameRequested, name_sz);
|
||||||
return(AUTH_VALID);
|
return(AUTH_VALID);
|
||||||
} else {
|
} else {
|
||||||
return(AUTH_USER);
|
return(AUTH_USER);
|
||||||
@@ -528,7 +530,6 @@ spx_printsub(data, cnt, buf, buflen)
|
|||||||
unsigned char *data, *buf;
|
unsigned char *data, *buf;
|
||||||
int cnt, buflen;
|
int cnt, buflen;
|
||||||
{
|
{
|
||||||
char lbuf[32];
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
buf[buflen-1] = '\0'; /* make sure its NULL terminated */
|
buf[buflen-1] = '\0'; /* make sure its NULL terminated */
|
||||||
@@ -536,11 +537,11 @@ spx_printsub(data, cnt, buf, buflen)
|
|||||||
|
|
||||||
switch(data[3]) {
|
switch(data[3]) {
|
||||||
case SPX_REJECT: /* Rejected (reason might follow) */
|
case SPX_REJECT: /* Rejected (reason might follow) */
|
||||||
strncpy((char *)buf, " REJECT ", buflen);
|
strcpy_truncate((char *)buf, " REJECT ", buflen);
|
||||||
goto common;
|
goto common;
|
||||||
|
|
||||||
case SPX_ACCEPT: /* Accepted (name might follow) */
|
case SPX_ACCEPT: /* Accepted (name might follow) */
|
||||||
strncpy((char *)buf, " ACCEPT ", buflen);
|
strcpy_truncate((char *)buf, " ACCEPT ", buflen);
|
||||||
common:
|
common:
|
||||||
BUMP(buf, buflen);
|
BUMP(buf, buflen);
|
||||||
if (cnt <= 4)
|
if (cnt <= 4)
|
||||||
@@ -553,17 +554,15 @@ spx_printsub(data, cnt, buf, buflen)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SPX_AUTH: /* Authentication data follows */
|
case SPX_AUTH: /* Authentication data follows */
|
||||||
strncpy((char *)buf, " AUTH", buflen);
|
strcpy_truncate((char *)buf, " AUTH", buflen);
|
||||||
goto common2;
|
goto common2;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
snprintf(lbuf, sizeof(lbuf), " %d (unknown)", data[3]);
|
snprintf(buf, buflen, " %d (unknown)", data[3]);
|
||||||
strncpy((char *)buf, lbuf, buflen);
|
|
||||||
common2:
|
common2:
|
||||||
BUMP(buf, buflen);
|
BUMP(buf, buflen);
|
||||||
for (i = 4; i < cnt; i++) {
|
for (i = 4; i < cnt; i++) {
|
||||||
snprintf(lbuf, sizeof(lbuf), " %d", data[i]);
|
snprintf(buf, buflen, " %d", data[i]);
|
||||||
strncpy((char *)buf, lbuf, buflen);
|
|
||||||
BUMP(buf, buflen);
|
BUMP(buf, buflen);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@@ -84,7 +84,7 @@ telnet_gets(char *prompt, char *result, int length, int echo)
|
|||||||
printf("%s", prompt);
|
printf("%s", prompt);
|
||||||
res = fgets(result, length, stdin);
|
res = fgets(result, length, stdin);
|
||||||
} else if ((res = getpass(prompt))) {
|
} else if ((res = getpass(prompt))) {
|
||||||
strncpy(result, res, length);
|
strcpy_truncate(result, res, length);
|
||||||
res = result;
|
res = result;
|
||||||
}
|
}
|
||||||
TerminalNewMode(om);
|
TerminalNewMode(om);
|
||||||
|
@@ -66,7 +66,8 @@ makeargv()
|
|||||||
margc = 0;
|
margc = 0;
|
||||||
cp = line;
|
cp = line;
|
||||||
if (*cp == '!') { /* Special case shell escape */
|
if (*cp == '!') { /* Special case shell escape */
|
||||||
strcpy(saveline, line); /* save for shell command */
|
/* save for shell command */
|
||||||
|
strcpy_truncate(saveline, line, sizeof(saveline));
|
||||||
*argp++ = "!"; /* No room in string to get this */
|
*argp++ = "!"; /* No room in string to get this */
|
||||||
margc++;
|
margc++;
|
||||||
cp++;
|
cp++;
|
||||||
@@ -1561,9 +1562,8 @@ env_init(void)
|
|||||||
/* If this is not the full name, try to get it via DNS */
|
/* If this is not the full name, try to get it via DNS */
|
||||||
if (strchr(hbuf, '.') == 0) {
|
if (strchr(hbuf, '.') == 0) {
|
||||||
struct hostent *he = roken_gethostbyname(hbuf);
|
struct hostent *he = roken_gethostbyname(hbuf);
|
||||||
if (he != 0)
|
if (he != NULL)
|
||||||
strncpy(hbuf, he->h_name, 256);
|
strcpy_truncate(hbuf, he->h_name, 256);
|
||||||
hbuf[256] = '\0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
asprintf (&cp, "%s%s", hbuf, cp2);
|
asprintf (&cp, "%s%s", hbuf, cp2);
|
||||||
@@ -1939,7 +1939,7 @@ status(int argc, char **argv)
|
|||||||
* Function that gets called when SIGINFO is received.
|
* Function that gets called when SIGINFO is received.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
ayt_status(void)
|
ayt_status(int ignore)
|
||||||
{
|
{
|
||||||
call(status, "status", "notmuch", 0);
|
call(status, "status", "notmuch", 0);
|
||||||
}
|
}
|
||||||
@@ -1961,7 +1961,7 @@ cmdrc(char *m1, char *m2)
|
|||||||
if (skiprc)
|
if (skiprc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
strcpy(m1save, m1);
|
strcpy_truncate(m1save, m1, sizeof(m1save));
|
||||||
m1 = m1save;
|
m1 = m1save;
|
||||||
|
|
||||||
if (rcname[0] == 0) {
|
if (rcname[0] == 0) {
|
||||||
@@ -2033,8 +2033,8 @@ tn(int argc, char **argv)
|
|||||||
struct sockaddr_in6 sin6;
|
struct sockaddr_in6 sin6;
|
||||||
#endif
|
#endif
|
||||||
struct sockaddr_in sin;
|
struct sockaddr_in sin;
|
||||||
struct sockaddr *sa;
|
struct sockaddr *sa = NULL;
|
||||||
int sa_size;
|
int sa_size = 0;
|
||||||
struct servent *sp = 0;
|
struct servent *sp = 0;
|
||||||
unsigned long temp;
|
unsigned long temp;
|
||||||
extern char *inet_ntoa();
|
extern char *inet_ntoa();
|
||||||
@@ -2042,8 +2042,9 @@ tn(int argc, char **argv)
|
|||||||
char *srp = 0;
|
char *srp = 0;
|
||||||
int srlen;
|
int srlen;
|
||||||
#endif
|
#endif
|
||||||
char *cmd, *hostp = 0, *portp = 0, *user = 0;
|
char *cmd, *hostp = 0, *portp = 0;
|
||||||
int family, port;
|
char *user = 0;
|
||||||
|
int family, port = 0;
|
||||||
|
|
||||||
/* clear the socket address prior to use */
|
/* clear the socket address prior to use */
|
||||||
|
|
||||||
@@ -2053,7 +2054,7 @@ tn(int argc, char **argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
strcpy(line, "open ");
|
strcpy_truncate(line, "open ", sizeof(line));
|
||||||
printf("(to) ");
|
printf("(to) ");
|
||||||
fgets(&line[strlen(line)], sizeof(line) - strlen(line), stdin);
|
fgets(&line[strlen(line)], sizeof(line) - strlen(line), stdin);
|
||||||
makeargv();
|
makeargv();
|
||||||
@@ -2124,7 +2125,7 @@ tn(int argc, char **argv)
|
|||||||
sin6.sin6_family = family = AF_INET6;
|
sin6.sin6_family = family = AF_INET6;
|
||||||
sa = (struct sockaddr *)&sin6;
|
sa = (struct sockaddr *)&sin6;
|
||||||
sa_size = sizeof(sin6);
|
sa_size = sizeof(sin6);
|
||||||
strcpy(_hostname, hostp);
|
strcpy_truncate(_hostname, hostp, sizeof(_hostname));
|
||||||
hostname =_hostname;
|
hostname =_hostname;
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
@@ -2132,7 +2133,7 @@ tn(int argc, char **argv)
|
|||||||
sin.sin_family = family = AF_INET;
|
sin.sin_family = family = AF_INET;
|
||||||
sa = (struct sockaddr *)&sin;
|
sa = (struct sockaddr *)&sin;
|
||||||
sa_size = sizeof(sin);
|
sa_size = sizeof(sin);
|
||||||
strcpy(_hostname, hostp);
|
strcpy_truncate(_hostname, hostp, sizeof(_hostname));
|
||||||
hostname = _hostname;
|
hostname = _hostname;
|
||||||
} else {
|
} else {
|
||||||
#ifdef HAVE_GETHOSTBYNAME2
|
#ifdef HAVE_GETHOSTBYNAME2
|
||||||
@@ -2143,7 +2144,7 @@ tn(int argc, char **argv)
|
|||||||
host = roken_gethostbyname(hostp);
|
host = roken_gethostbyname(hostp);
|
||||||
#endif
|
#endif
|
||||||
if (host) {
|
if (host) {
|
||||||
strncpy(_hostname, host->h_name, sizeof(_hostname));
|
strcpy_truncate(_hostname, host->h_name, sizeof(_hostname));
|
||||||
family = host->h_addrtype;
|
family = host->h_addrtype;
|
||||||
|
|
||||||
switch(family) {
|
switch(family) {
|
||||||
@@ -2253,7 +2254,7 @@ tn(int argc, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
#if defined(IPPROTO_IP) && defined(IP_TOS)
|
#if defined(IPPROTO_IP) && defined(IP_TOS)
|
||||||
{
|
{
|
||||||
# if defined(HAS_GETTOS)
|
# if defined(HAVE_GETTOSBYNAME)
|
||||||
struct tosent *tp;
|
struct tosent *tp;
|
||||||
if (tos < 0 && (tp = gettosbyname("telnet", "tcp")))
|
if (tos < 0 && (tp = gettosbyname("telnet", "tcp")))
|
||||||
tos = tp->t_tos;
|
tos = tp->t_tos;
|
||||||
@@ -2316,7 +2317,7 @@ tn(int argc, char **argv)
|
|||||||
|
|
||||||
user = getenv("USER");
|
user = getenv("USER");
|
||||||
if (user == NULL ||
|
if (user == NULL ||
|
||||||
((pw = k_getpwnam(user)) && pw->pw_uid != getuid())) {
|
((pw = k_getpwnam((char *)user)) && pw->pw_uid != getuid())) {
|
||||||
if ((pw = k_getpwuid(getuid())))
|
if ((pw = k_getpwuid(getuid())))
|
||||||
user = pw->pw_name;
|
user = pw->pw_name;
|
||||||
else
|
else
|
||||||
@@ -2329,7 +2330,7 @@ tn(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
call(status, "status", "notmuch", 0);
|
call(status, "status", "notmuch", 0);
|
||||||
if (setjmp(peerdied) == 0)
|
if (setjmp(peerdied) == 0)
|
||||||
telnet(user);
|
my_telnet((char *)user);
|
||||||
NetClose(net);
|
NetClose(net);
|
||||||
ExitString("Connection closed by foreign host.\r\n",1);
|
ExitString("Connection closed by foreign host.\r\n",1);
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
|
@@ -167,7 +167,7 @@ extern int (*decrypt_input) (int);
|
|||||||
|
|
||||||
extern FILE
|
extern FILE
|
||||||
*NetTrace; /* Where debugging output goes */
|
*NetTrace; /* Where debugging output goes */
|
||||||
extern unsigned char
|
extern char
|
||||||
NetTraceFile[]; /* Name of file where debugging output goes */
|
NetTraceFile[]; /* Name of file where debugging output goes */
|
||||||
extern void
|
extern void
|
||||||
SetNetTrace (char *); /* Function to change where debugging goes */
|
SetNetTrace (char *); /* Function to change where debugging goes */
|
||||||
@@ -222,7 +222,7 @@ int EncryptStatus (void);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SIGINFO
|
#ifdef SIGINFO
|
||||||
void ayt_status(void);
|
void ayt_status(int);
|
||||||
#endif
|
#endif
|
||||||
int tn(int argc, char **argv);
|
int tn(int argc, char **argv);
|
||||||
void command(int top, char *tbuf, int cnt);
|
void command(int top, char *tbuf, int cnt);
|
||||||
@@ -281,13 +281,13 @@ void xmitEC(void);
|
|||||||
|
|
||||||
void Dump (char, unsigned char *, int);
|
void Dump (char, unsigned char *, int);
|
||||||
void printoption (char *, int, int);
|
void printoption (char *, int, int);
|
||||||
void printsub (char, unsigned char *, int);
|
void printsub (int, unsigned char *, int);
|
||||||
void sendnaws (void);
|
void sendnaws (void);
|
||||||
void setconnmode (int);
|
void setconnmode (int);
|
||||||
void setcommandmode (void);
|
void setcommandmode (void);
|
||||||
void setneturg (void);
|
void setneturg (void);
|
||||||
void sys_telnet_init (void);
|
void sys_telnet_init (void);
|
||||||
void telnet (char *);
|
void my_telnet (char *);
|
||||||
void tel_enter_binary (int);
|
void tel_enter_binary (int);
|
||||||
void TerminalFlushOutput (void);
|
void TerminalFlushOutput (void);
|
||||||
void TerminalNewMode (int);
|
void TerminalNewMode (int);
|
||||||
@@ -351,7 +351,7 @@ void SetNetTrace(char *file);
|
|||||||
void Dump(char direction, unsigned char *buffer, int length);
|
void Dump(char direction, unsigned char *buffer, int length);
|
||||||
void printoption(char *direction, int cmd, int option);
|
void printoption(char *direction, int cmd, int option);
|
||||||
void optionstatus(void);
|
void optionstatus(void);
|
||||||
void printsub(char direction, unsigned char *pointer, int length);
|
void printsub(int direction, unsigned char *pointer, int length);
|
||||||
void EmptyTerminal(void);
|
void EmptyTerminal(void);
|
||||||
void SetForExit(void);
|
void SetForExit(void);
|
||||||
void Exit(int returnCode);
|
void Exit(int returnCode);
|
||||||
|
@@ -168,7 +168,7 @@ main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
case 'S':
|
case 'S':
|
||||||
{
|
{
|
||||||
#ifdef HAS_GETTOS
|
#ifdef HAVE_PARSETOS
|
||||||
extern int tos;
|
extern int tos;
|
||||||
|
|
||||||
if ((tos = parsetos(optarg, "tcp")) < 0)
|
if ((tos = parsetos(optarg, "tcp")) < 0)
|
||||||
@@ -237,7 +237,7 @@ main(int argc, char **argv)
|
|||||||
extern char *dest_realm, dst_realm_buf[];
|
extern char *dest_realm, dst_realm_buf[];
|
||||||
extern int dst_realm_sz;
|
extern int dst_realm_sz;
|
||||||
dest_realm = dst_realm_buf;
|
dest_realm = dst_realm_buf;
|
||||||
strncpy(dest_realm, optarg, dst_realm_sz);
|
strcpy_truncate(dest_realm, optarg, dst_realm_sz);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
|
@@ -713,7 +713,7 @@ ayt(int sig)
|
|||||||
if (connected)
|
if (connected)
|
||||||
sendayt();
|
sendayt();
|
||||||
else
|
else
|
||||||
ayt_status();
|
ayt_status(sig);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -32,6 +32,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "telnet_locl.h"
|
#include "telnet_locl.h"
|
||||||
|
#ifdef HAVE_TERMCAP_H
|
||||||
|
#include <termcap.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
RCSID("$Id$");
|
RCSID("$Id$");
|
||||||
|
|
||||||
@@ -107,7 +110,7 @@ unsigned char telopt_environ = TELOPT_NEW_ENVIRON;
|
|||||||
# define telopt_environ TELOPT_NEW_ENVIRON
|
# define telopt_environ TELOPT_NEW_ENVIRON
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
jmp_buf toplevel = { 0 };
|
jmp_buf toplevel;
|
||||||
jmp_buf peerdied;
|
jmp_buf peerdied;
|
||||||
|
|
||||||
int flushline;
|
int flushline;
|
||||||
@@ -1550,7 +1553,7 @@ telrcv(void)
|
|||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
int scc;
|
int scc;
|
||||||
unsigned char *sbp;
|
unsigned char *sbp = NULL;
|
||||||
int count;
|
int count;
|
||||||
int returnValue = 0;
|
int returnValue = 0;
|
||||||
|
|
||||||
@@ -1795,7 +1798,7 @@ telsnd()
|
|||||||
int tcc;
|
int tcc;
|
||||||
int count;
|
int count;
|
||||||
int returnValue = 0;
|
int returnValue = 0;
|
||||||
unsigned char *tbp;
|
unsigned char *tbp = NULL;
|
||||||
|
|
||||||
tcc = 0;
|
tcc = 0;
|
||||||
count = 0;
|
count = 0;
|
||||||
@@ -1991,7 +1994,7 @@ Scheduler(int block) /* should we block in the select ? */
|
|||||||
* Select from tty and network...
|
* Select from tty and network...
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
telnet(char *user)
|
my_telnet(char *user)
|
||||||
{
|
{
|
||||||
sys_telnet_init();
|
sys_telnet_init();
|
||||||
|
|
||||||
|
@@ -72,7 +72,7 @@ SetSockOpt(int fd, int level, int option, int yesno)
|
|||||||
* The following are routines used to print out debugging information.
|
* The following are routines used to print out debugging information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
unsigned char NetTraceFile[256] = "(standard output)";
|
char NetTraceFile[256] = "(standard output)";
|
||||||
|
|
||||||
void
|
void
|
||||||
SetNetTrace(char *file)
|
SetNetTrace(char *file)
|
||||||
@@ -82,13 +82,13 @@ SetNetTrace(char *file)
|
|||||||
if (file && (strcmp(file, "-") != 0)) {
|
if (file && (strcmp(file, "-") != 0)) {
|
||||||
NetTrace = fopen(file, "w");
|
NetTrace = fopen(file, "w");
|
||||||
if (NetTrace) {
|
if (NetTrace) {
|
||||||
strcpy((char *)NetTraceFile, file);
|
strcpy_truncate(NetTraceFile, file, sizeof(NetTraceFile));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fprintf(stderr, "Cannot open %s.\n", file);
|
fprintf(stderr, "Cannot open %s.\n", file);
|
||||||
}
|
}
|
||||||
NetTrace = stdout;
|
NetTrace = stdout;
|
||||||
strcpy((char *)NetTraceFile, "(standard output)");
|
strcpy_truncate(NetTraceFile, "(standard output)", sizeof(NetTraceFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -250,7 +250,7 @@ optionstatus(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printsub(char direction, unsigned char *pointer, int length)
|
printsub(int direction, unsigned char *pointer, int length)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
unsigned char buf[512];
|
unsigned char buf[512];
|
||||||
|
@@ -122,11 +122,11 @@ void start_login (char *host, int autologin, char *name);
|
|||||||
void cleanup (int sig);
|
void cleanup (int sig);
|
||||||
int main (int argc, char **argv);
|
int main (int argc, char **argv);
|
||||||
void usage (void);
|
void usage (void);
|
||||||
int getterminaltype (char *name);
|
int getterminaltype (char *name, size_t);
|
||||||
void _gettermname (void);
|
void _gettermname (void);
|
||||||
int terminaltypeok (char *s);
|
int terminaltypeok (char *s);
|
||||||
void doit (struct sockaddr_in *who);
|
void doit (struct sockaddr_in *who);
|
||||||
void telnet (int f, int p, char*, int, char*);
|
void my_telnet (int f, int p, char*, int, char*);
|
||||||
void interrupt (void);
|
void interrupt (void);
|
||||||
void sendbrk (void);
|
void sendbrk (void);
|
||||||
void sendsusp (void);
|
void sendsusp (void);
|
||||||
@@ -150,7 +150,7 @@ void putf (char *cp, char *where);
|
|||||||
void printoption (char *fmt, int option);
|
void printoption (char *fmt, int option);
|
||||||
void printsub (int direction, unsigned char *pointer, int length);
|
void printsub (int direction, unsigned char *pointer, int length);
|
||||||
void printdata (char *tag, char *ptr, int cnt);
|
void printdata (char *tag, char *ptr, int cnt);
|
||||||
|
int login_tty(int t);
|
||||||
|
|
||||||
#ifdef ENCRYPTION
|
#ifdef ENCRYPTION
|
||||||
extern void (*encrypt_output) (unsigned char *, int);
|
extern void (*encrypt_output) (unsigned char *, int);
|
||||||
|
@@ -360,7 +360,7 @@ char *line = Xline;
|
|||||||
char myline[] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
|
char myline[] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
|
||||||
#endif /* CRAY */
|
#endif /* CRAY */
|
||||||
|
|
||||||
#ifndef HAVE_PTSNAME
|
#if !defined(HAVE_PTSNAME) && defined(STREAMSPTY)
|
||||||
static char *ptsname(int fd)
|
static char *ptsname(int fd)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_TTYNAME
|
#ifdef HAVE_TTYNAME
|
||||||
@@ -388,7 +388,7 @@ int getpty(int *ptynum)
|
|||||||
p = _getpty(&master, O_RDWR, 0600, 1);
|
p = _getpty(&master, O_RDWR, 0600, 1);
|
||||||
if(p == NULL)
|
if(p == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
strcpy(line, p);
|
strcpy_truncate(line, p, sizeof(Xline));
|
||||||
return master;
|
return master;
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@@ -420,7 +420,7 @@ int getpty(int *ptynum)
|
|||||||
#ifdef HAVE_UNLOCKPT
|
#ifdef HAVE_UNLOCKPT
|
||||||
unlockpt(p);
|
unlockpt(p);
|
||||||
#endif
|
#endif
|
||||||
strcpy(line, ptsname(p));
|
strcpy_truncate(line, ptsname(p), sizeof(Xline));
|
||||||
really_stream = 1;
|
really_stream = 1;
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
@@ -1087,6 +1087,7 @@ clean_ttyname (char *tty)
|
|||||||
* Generate a name usable as an `ut_id', typically without `tty'.
|
* Generate a name usable as an `ut_id', typically without `tty'.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_UT_ID
|
||||||
static char *
|
static char *
|
||||||
make_id (char *tty)
|
make_id (char *tty)
|
||||||
{
|
{
|
||||||
@@ -1098,6 +1099,7 @@ make_id (char *tty)
|
|||||||
res += 3;
|
res += 3;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* startslave(host)
|
* startslave(host)
|
||||||
@@ -1190,7 +1192,7 @@ init_env(void)
|
|||||||
char **envp;
|
char **envp;
|
||||||
|
|
||||||
envp = envinit;
|
envp = envinit;
|
||||||
if (*envp = getenv("TZ"))
|
if ((*envp = getenv("TZ")))
|
||||||
*envp++ -= 3;
|
*envp++ -= 3;
|
||||||
#if defined(_CRAY) || defined(__hpux)
|
#if defined(_CRAY) || defined(__hpux)
|
||||||
else
|
else
|
||||||
@@ -1392,7 +1394,7 @@ rmut(void)
|
|||||||
utmpx.ut_type = LOGIN_PROCESS;
|
utmpx.ut_type = LOGIN_PROCESS;
|
||||||
utxp = getutxline(&utmpx);
|
utxp = getutxline(&utmpx);
|
||||||
if (utxp) {
|
if (utxp) {
|
||||||
strcpy(utxp->ut_user, "");
|
utxp->ut_user[0] = '\0';
|
||||||
utxp->ut_type = DEAD_PROCESS;
|
utxp->ut_type = DEAD_PROCESS;
|
||||||
#ifdef HAVE_UT_EXIT
|
#ifdef HAVE_UT_EXIT
|
||||||
#ifdef _STRUCT___EXIT_STATUS
|
#ifdef _STRUCT___EXIT_STATUS
|
||||||
|
@@ -275,7 +275,7 @@ int main(int argc, char **argv)
|
|||||||
#endif /* CRAY */
|
#endif /* CRAY */
|
||||||
|
|
||||||
case 'S':
|
case 'S':
|
||||||
#ifdef HAS_GETTOS
|
#ifdef HAVE_PARSETOS
|
||||||
if ((tos = parsetos(optarg, "tcp")) < 0)
|
if ((tos = parsetos(optarg, "tcp")) < 0)
|
||||||
fprintf(stderr, "%s%s%s\n",
|
fprintf(stderr, "%s%s%s\n",
|
||||||
"telnetd: Bad TOS argument '", optarg,
|
"telnetd: Bad TOS argument '", optarg,
|
||||||
@@ -329,7 +329,7 @@ int main(int argc, char **argv)
|
|||||||
argv += optind;
|
argv += optind;
|
||||||
|
|
||||||
if (debug) {
|
if (debug) {
|
||||||
int port;
|
int port = 0;
|
||||||
struct servent *sp;
|
struct servent *sp;
|
||||||
|
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
@@ -423,7 +423,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
#if defined(IPPROTO_IP) && defined(IP_TOS) && defined(HAVE_SETSOCKOPT)
|
#if defined(IPPROTO_IP) && defined(IP_TOS) && defined(HAVE_SETSOCKOPT)
|
||||||
{
|
{
|
||||||
# ifdef HAS_GETTOS
|
# ifdef HAVE_GETTOSBYNAME
|
||||||
struct tosent *tp;
|
struct tosent *tp;
|
||||||
if (tos < 0 && (tp = gettosbyname("telnet", "tcp")))
|
if (tos < 0 && (tp = gettosbyname("telnet", "tcp")))
|
||||||
tos = tp->t_tos;
|
tos = tp->t_tos;
|
||||||
@@ -440,6 +440,7 @@ int main(int argc, char **argv)
|
|||||||
net = 0;
|
net = 0;
|
||||||
doit(&from);
|
doit(&from);
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
|
return 0;
|
||||||
} /* end of main */
|
} /* end of main */
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -463,7 +464,7 @@ usage()
|
|||||||
fprintf(stderr, " [-r[lowpty]-[highpty]]");
|
fprintf(stderr, " [-r[lowpty]-[highpty]]");
|
||||||
#endif
|
#endif
|
||||||
fprintf(stderr, "\n\t");
|
fprintf(stderr, "\n\t");
|
||||||
#ifdef HAS_GETTOS
|
#ifdef HAVE_GETTOSBYNAME
|
||||||
fprintf(stderr, " [-S tos]");
|
fprintf(stderr, " [-S tos]");
|
||||||
#endif
|
#endif
|
||||||
#ifdef AUTHENTICATION
|
#ifdef AUTHENTICATION
|
||||||
@@ -485,7 +486,7 @@ static unsigned char ttytype_sbbuf[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
getterminaltype(char *name)
|
getterminaltype(char *name, size_t name_sz)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
void _gettermname();
|
void _gettermname();
|
||||||
@@ -499,7 +500,7 @@ getterminaltype(char *name)
|
|||||||
while (his_will_wont_is_changing(TELOPT_AUTHENTICATION))
|
while (his_will_wont_is_changing(TELOPT_AUTHENTICATION))
|
||||||
ttloop();
|
ttloop();
|
||||||
if (his_state_is_will(TELOPT_AUTHENTICATION)) {
|
if (his_state_is_will(TELOPT_AUTHENTICATION)) {
|
||||||
retval = auth_wait(name);
|
retval = auth_wait(name, name_sz);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -593,12 +594,12 @@ getterminaltype(char *name)
|
|||||||
* we have to just go with what we (might) have already gotten.
|
* we have to just go with what we (might) have already gotten.
|
||||||
*/
|
*/
|
||||||
if (his_state_is_will(TELOPT_TTYPE) && !terminaltypeok(terminaltype)) {
|
if (his_state_is_will(TELOPT_TTYPE) && !terminaltypeok(terminaltype)) {
|
||||||
strncpy(first, terminaltype, sizeof(first));
|
strcpy_truncate(first, terminaltype, sizeof(first));
|
||||||
for(;;) {
|
for(;;) {
|
||||||
/*
|
/*
|
||||||
* Save the unknown name, and request the next name.
|
* Save the unknown name, and request the next name.
|
||||||
*/
|
*/
|
||||||
strncpy(last, terminaltype, sizeof(last));
|
strcpy_truncate(last, terminaltype, sizeof(last));
|
||||||
_gettermname();
|
_gettermname();
|
||||||
if (terminaltypeok(terminaltype))
|
if (terminaltypeok(terminaltype))
|
||||||
break;
|
break;
|
||||||
@@ -661,7 +662,7 @@ char remote_host_name[MaxHostNameLen];
|
|||||||
void
|
void
|
||||||
doit(struct sockaddr_in *who)
|
doit(struct sockaddr_in *who)
|
||||||
{
|
{
|
||||||
char *host;
|
char *host = NULL;
|
||||||
struct hostent *hp;
|
struct hostent *hp;
|
||||||
int level;
|
int level;
|
||||||
int ptynum;
|
int ptynum;
|
||||||
@@ -707,8 +708,7 @@ Please contact your net administrator");
|
|||||||
* We must make a copy because Kerberos is probably going
|
* We must make a copy because Kerberos is probably going
|
||||||
* to also do a gethost* and overwrite the static data...
|
* to also do a gethost* and overwrite the static data...
|
||||||
*/
|
*/
|
||||||
strncpy(remote_host_name, host, sizeof(remote_host_name)-1);
|
strcpy_truncate(remote_host_name, host, sizeof(remote_host_name));
|
||||||
remote_host_name[sizeof(remote_host_name)-1] = 0;
|
|
||||||
host = remote_host_name;
|
host = remote_host_name;
|
||||||
|
|
||||||
/* XXX - should be k_gethostname? */
|
/* XXX - should be k_gethostname? */
|
||||||
@@ -732,9 +732,9 @@ Please contact your net administrator");
|
|||||||
* If hostname still doesn't fit utmp, use ipaddr.
|
* If hostname still doesn't fit utmp, use ipaddr.
|
||||||
*/
|
*/
|
||||||
if (strlen(remote_host_name) > abs(utmp_len))
|
if (strlen(remote_host_name) > abs(utmp_len))
|
||||||
strncpy(remote_host_name,
|
strcpy_truncate(remote_host_name,
|
||||||
inet_ntoa(who->sin_addr),
|
inet_ntoa(who->sin_addr),
|
||||||
sizeof(remote_host_name)-1);
|
sizeof(remote_host_name));
|
||||||
|
|
||||||
#ifdef AUTHENTICATION
|
#ifdef AUTHENTICATION
|
||||||
auth_encrypt_init(hostname, host, "TELNETD", 1);
|
auth_encrypt_init(hostname, host, "TELNETD", 1);
|
||||||
@@ -745,7 +745,7 @@ Please contact your net administrator");
|
|||||||
* get terminal type.
|
* get terminal type.
|
||||||
*/
|
*/
|
||||||
*user_name = 0;
|
*user_name = 0;
|
||||||
level = getterminaltype(user_name);
|
level = getterminaltype(user_name, sizeof(user_name));
|
||||||
setenv("TERM", terminaltype ? terminaltype : "network", 1);
|
setenv("TERM", terminaltype ? terminaltype : "network", 1);
|
||||||
|
|
||||||
#ifdef _SC_CRAY_SECURE_SYS
|
#ifdef _SC_CRAY_SECURE_SYS
|
||||||
@@ -757,7 +757,8 @@ Please contact your net administrator");
|
|||||||
}
|
}
|
||||||
#endif /* _SC_CRAY_SECURE_SYS */
|
#endif /* _SC_CRAY_SECURE_SYS */
|
||||||
|
|
||||||
telnet(net, ourpty, host, level, user_name); /* begin server processing */
|
/* begin server processing */
|
||||||
|
my_telnet(net, ourpty, host, level, user_name);
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
} /* end of doit */
|
} /* end of doit */
|
||||||
|
|
||||||
@@ -784,17 +785,11 @@ show_issue(void)
|
|||||||
* hand data to telnet receiver finite state machine.
|
* hand data to telnet receiver finite state machine.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
telnet(int f, int p, char *host, int level, char *autoname)
|
my_telnet(int f, int p, char *host, int level, char *autoname)
|
||||||
{
|
{
|
||||||
int on = 1;
|
int on = 1;
|
||||||
#define TABBUFSIZ 512
|
|
||||||
char defent[TABBUFSIZ];
|
|
||||||
char defstrs[TABBUFSIZ];
|
|
||||||
#undef TABBUFSIZ
|
|
||||||
char *he;
|
char *he;
|
||||||
char *HN;
|
|
||||||
char *IM;
|
char *IM;
|
||||||
void netflush();
|
|
||||||
int nfd;
|
int nfd;
|
||||||
int startslave_called = 0;
|
int startslave_called = 0;
|
||||||
time_t timeout;
|
time_t timeout;
|
||||||
|
@@ -175,6 +175,10 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBUTIL_H
|
||||||
|
#include <libutil.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <roken.h>
|
#include <roken.h>
|
||||||
|
|
||||||
/* Don't use the system login, use our version instead */
|
/* Don't use the system login, use our version instead */
|
||||||
|
@@ -391,8 +391,8 @@ void edithost(char *pat, char *host)
|
|||||||
pat++;
|
pat++;
|
||||||
}
|
}
|
||||||
if (*host)
|
if (*host)
|
||||||
strncpy(res, host,
|
strcpy_truncate (res, host,
|
||||||
sizeof editedhost - (res - editedhost) -1);
|
sizeof editedhost - (res - editedhost));
|
||||||
else
|
else
|
||||||
*res = '\0';
|
*res = '\0';
|
||||||
editedhost[sizeof editedhost - 1] = '\0';
|
editedhost[sizeof editedhost - 1] = '\0';
|
||||||
@@ -527,7 +527,7 @@ printsub(int direction, unsigned char *pointer, int length)
|
|||||||
/* where suboption data sits */
|
/* where suboption data sits */
|
||||||
/* length of suboption data */
|
/* length of suboption data */
|
||||||
{
|
{
|
||||||
int i;
|
int i = 0;
|
||||||
unsigned char buf[512];
|
unsigned char buf[512];
|
||||||
|
|
||||||
if (!(diagnostic & TD_OPTIONS))
|
if (!(diagnostic & TD_OPTIONS))
|
||||||
|
@@ -10,6 +10,10 @@ Sat Mar 21 14:36:21 1998 Assar Westerlund <assar@sics.se>
|
|||||||
|
|
||||||
* xnlock.c (init_words): recognize both `-p' and `-prog'
|
* xnlock.c (init_words): recognize both `-p' and `-prog'
|
||||||
|
|
||||||
|
Sat Feb 7 10:08:07 1998 Assar Westerlund <assar@sics.se>
|
||||||
|
|
||||||
|
* xnlock.c: Don't use REALM_SZ + 1, just REALM_SZ
|
||||||
|
|
||||||
Sat Nov 29 04:58:19 1997 Johan Danielsson <joda@emma.pdc.kth.se>
|
Sat Nov 29 04:58:19 1997 Johan Danielsson <joda@emma.pdc.kth.se>
|
||||||
|
|
||||||
* xnlock.c: Make it build w/o krb4.
|
* xnlock.c: Make it build w/o krb4.
|
||||||
|
@@ -47,7 +47,7 @@ static char userprompt[128];
|
|||||||
#ifdef KRB4
|
#ifdef KRB4
|
||||||
static char name[ANAME_SZ];
|
static char name[ANAME_SZ];
|
||||||
static char inst[INST_SZ];
|
static char inst[INST_SZ];
|
||||||
static char realm[REALM_SZ + 1];
|
static char realm[REALM_SZ];
|
||||||
#endif
|
#endif
|
||||||
#ifdef KRB5
|
#ifdef KRB5
|
||||||
static krb5_context context;
|
static krb5_context context;
|
||||||
@@ -251,8 +251,8 @@ init_words (int argc, char **argv)
|
|||||||
errx (1, "cannot allocate memory for message");
|
errx (1, "cannot allocate memory for message");
|
||||||
appres.text[0] = 0;
|
appres.text[0] = 0;
|
||||||
for(; i < j; i++){
|
for(; i < j; i++){
|
||||||
strcat(appres.text, argv[i]);
|
strcat_truncate(appres.text, argv[i], len);
|
||||||
strcat(appres.text, " ");
|
strcat_truncate(appres.text, " ", len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -798,7 +798,8 @@ talk(int force_erase)
|
|||||||
XSetForeground(dpy, gc, White);
|
XSetForeground(dpy, gc, White);
|
||||||
talking = 1;
|
talking = 1;
|
||||||
walk(FRONT);
|
walk(FRONT);
|
||||||
p = strcpy(buf, words);
|
strcpy_truncate (buf, words, sizeof(buf));
|
||||||
|
p = buf;
|
||||||
|
|
||||||
/* possibly avoid a lot of work here
|
/* possibly avoid a lot of work here
|
||||||
* if no CR or only one, then just print the line
|
* if no CR or only one, then just print the line
|
||||||
@@ -832,7 +833,7 @@ talk(int force_erase)
|
|||||||
if ((w = XTextWidth(font, p, p2 - p)) > width)
|
if ((w = XTextWidth(font, p, p2 - p)) > width)
|
||||||
width = w;
|
width = w;
|
||||||
total += p2 - p; /* total chars; count to determine reading time */
|
total += p2 - p; /* total chars; count to determine reading time */
|
||||||
strcpy(args[height], p);
|
strcpy_truncate(args[height], p, sizeof(args[height]));
|
||||||
if (height == MAXLINES - 1) {
|
if (height == MAXLINES - 1) {
|
||||||
puts("Message too long!");
|
puts("Message too long!");
|
||||||
break;
|
break;
|
||||||
@@ -927,15 +928,14 @@ main (int argc, char **argv)
|
|||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
if (!(pw = k_getpwuid(0)))
|
if (!(pw = k_getpwuid(0)))
|
||||||
errx (1, "can't get root's passwd!");
|
errx (1, "can't get root's passwd!");
|
||||||
strcpy(root_cpass, pw->pw_passwd);
|
strcpy_truncate(root_cpass, pw->pw_passwd, sizeof(root_cpass));
|
||||||
|
|
||||||
if (!(pw = k_getpwuid(getuid())))
|
if (!(pw = k_getpwuid(getuid())))
|
||||||
errx (1, "Can't get your password entry!");
|
errx (1, "Can't get your password entry!");
|
||||||
strcpy(user_cpass, pw->pw_passwd);
|
strcpy_truncate(user_cpass, pw->pw_passwd, sizeof(user_cpass));
|
||||||
setuid(getuid());
|
setuid(getuid());
|
||||||
/* Now we're no longer running setuid root. */
|
/* Now we're no longer running setuid root. */
|
||||||
strncpy(login, pw->pw_name, sizeof(login));
|
strcpy_truncate(login, pw->pw_name, sizeof(login));
|
||||||
login[sizeof(login) - 1] = '\0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
srand(getpid());
|
srand(getpid());
|
||||||
|
@@ -58,7 +58,7 @@ afs_verify(char *name,
|
|||||||
int quiet)
|
int quiet)
|
||||||
{
|
{
|
||||||
int ret = 1;
|
int ret = 1;
|
||||||
char lrealm[REALM_SZ + 1];
|
char lrealm[REALM_SZ];
|
||||||
char tkt_string[MaxPathLen];
|
char tkt_string[MaxPathLen];
|
||||||
struct passwd *pwd;
|
struct passwd *pwd;
|
||||||
|
|
||||||
|
@@ -150,10 +150,10 @@ auth_su(pam_handle_t *pamh, int flags, char *user, struct pam_conv *conv)
|
|||||||
|
|
||||||
pw = getpwuid(getuid());
|
pw = getpwuid(getuid());
|
||||||
if(strcmp(user, "root") == 0){
|
if(strcmp(user, "root") == 0){
|
||||||
strcpy(pr.name, pw->pw_name);
|
strcpy_truncate(pr.name, pw->pw_name, sizeof(pr.name));
|
||||||
strcpy(pr.instance, "root");
|
strcpy_truncate(pr.instance, "root", sizeof(pr.instance));
|
||||||
}else{
|
}else{
|
||||||
strcpy(pr.name, user);
|
strcpy_truncate(pr.name, user, sizeof(pr.name));
|
||||||
pr.instance[0] = 0;
|
pr.instance[0] = 0;
|
||||||
}
|
}
|
||||||
pmsg = &msg;
|
pmsg = &msg;
|
||||||
|
@@ -363,8 +363,12 @@ siad_ses_suauthent(sia_collect_func_t *collect,
|
|||||||
return SIADFAIL;
|
return SIADFAIL;
|
||||||
if(entity->name == NULL)
|
if(entity->name == NULL)
|
||||||
return SIADFAIL;
|
return SIADFAIL;
|
||||||
if(entity->name[0] == 0)
|
if(entity->name[0] == 0) {
|
||||||
strcpy(entity->name, "root");
|
free(entity->name);
|
||||||
|
entity->name = strdup("root");
|
||||||
|
if (entity->name == NULL)
|
||||||
|
return SIADFAIL;
|
||||||
|
}
|
||||||
return common_auth(collect, entity, siastat, pkgind);
|
return common_auth(collect, entity, siastat, pkgind);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1997 Kungliga Tekniska H<>gskolan
|
* Copyright (c) 1997, 1998 Kungliga Tekniska H<>gskolan
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -43,6 +43,7 @@ RCSID("$Id$");
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <roken.h>
|
||||||
#include "com_err.h"
|
#include "com_err.h"
|
||||||
|
|
||||||
struct et_list *_et_list;
|
struct et_list *_et_list;
|
||||||
@@ -53,8 +54,7 @@ error_message (long code)
|
|||||||
static char msg[128];
|
static char msg[128];
|
||||||
const char *p = com_right(_et_list, code);
|
const char *p = com_right(_et_list, code);
|
||||||
if(p){
|
if(p){
|
||||||
strncpy(msg, p, sizeof(msg));
|
strcpy_truncate(msg, p, sizeof(msg));
|
||||||
msg[sizeof(msg)-1] = '\0';
|
|
||||||
} else{
|
} else{
|
||||||
snprintf(msg, sizeof(msg), "Unknown error %d", code);
|
snprintf(msg, sizeof(msg), "Unknown error %d", code);
|
||||||
}
|
}
|
||||||
@@ -76,18 +76,18 @@ default_proc (const char *whoami, long code, const char *fmt, va_list args)
|
|||||||
const void *arg[3], **ap = arg;
|
const void *arg[3], **ap = arg;
|
||||||
|
|
||||||
if(whoami) {
|
if(whoami) {
|
||||||
strcat(f, "%s: ");
|
strcat_truncate(f, "%s: ", sizeof(f));
|
||||||
*ap++ = whoami;
|
*ap++ = whoami;
|
||||||
}
|
}
|
||||||
if(code) {
|
if(code) {
|
||||||
strcat(f, "%s ");
|
strcat_truncate(f, "%s ", sizeof(f));
|
||||||
*ap++ = error_message(code);
|
*ap++ = error_message(code);
|
||||||
}
|
}
|
||||||
if(fmt) {
|
if(fmt) {
|
||||||
strcat(f, "%s");
|
strcat_truncate(f, "%s", sizeof(f));
|
||||||
*ap++ = fmt;
|
*ap++ = fmt;
|
||||||
}
|
}
|
||||||
strcat(f, "\r\n");
|
strcat_truncate(f, "\r\n", sizeof(f));
|
||||||
asprintf(&x, f, arg[0], arg[1], arg[2]);
|
asprintf(&x, f, arg[0], arg[1], arg[2]);
|
||||||
vfprintf(stderr, x, args);
|
vfprintf(stderr, x, args);
|
||||||
free(x);
|
free(x);
|
||||||
|
@@ -203,9 +203,8 @@ crypt_md5(pw, salt)
|
|||||||
MD5Update(&ctx, pw+j, 1);
|
MD5Update(&ctx, pw+j, 1);
|
||||||
|
|
||||||
/* Now make the output string */
|
/* Now make the output string */
|
||||||
strcpy(passwd,magic);
|
snprintf (passwd, sizeof(passwd),
|
||||||
strncat(passwd,sp,sl);
|
"%s%.*s$", magic, sl, sp);
|
||||||
strcat(passwd,"$");
|
|
||||||
|
|
||||||
MD5Final(final,&ctx);
|
MD5Final(final,&ctx);
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1995, 1996, 1997 Kungliga Tekniska H<>gskolan
|
* Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska H<>gskolan
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -84,12 +84,12 @@ pwd_dialog(char *buf, int size)
|
|||||||
switch(DialogBox(hInst,MAKEINTRESOURCE(IDD_PASSWD_DIALOG),wnd,pwd_dialog_proc))
|
switch(DialogBox(hInst,MAKEINTRESOURCE(IDD_PASSWD_DIALOG),wnd,pwd_dialog_proc))
|
||||||
{
|
{
|
||||||
case IDOK:
|
case IDOK:
|
||||||
strcpy(buf,passwd);
|
strcpy_truncate(buf, passwd, size);
|
||||||
for(i=0; passwd[i] != '\0'; i++) passwd[i] = '\0';
|
memset (passwd, 0, sizeof(passwd));
|
||||||
return 0;
|
return 0;
|
||||||
case IDCANCEL:
|
case IDCANCEL:
|
||||||
default:
|
default:
|
||||||
for(i=0; passwd[i] != '\0'; i++) passwd[i] = '\0';
|
memset (passwd, 0, sizeof(passwd));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,3 +10,10 @@ Sun Apr 19 09:53:46 1998 Assar Westerlund <assar@sics.se>
|
|||||||
|
|
||||||
* Makefile.in: add symlink magic for linux
|
* Makefile.in: add symlink magic for linux
|
||||||
|
|
||||||
|
Sat Feb 7 07:24:30 1998 Assar Westerlund <assar@sics.se>
|
||||||
|
|
||||||
|
* editline.h: add prototypes
|
||||||
|
|
||||||
|
Tue Feb 3 10:24:22 1998 Johan Danielsson <joda@emma.pdc.kth.se>
|
||||||
|
|
||||||
|
* editline.c: If read returns EINTR, try again.
|
||||||
|
@@ -169,9 +169,8 @@ rl_complete(pathname, unique)
|
|||||||
if ((p = NEW(char, j + 1)) != NULL) {
|
if ((p = NEW(char, j + 1)) != NULL) {
|
||||||
COPYFROMTO(p, av[0] + len, j);
|
COPYFROMTO(p, av[0] + len, j);
|
||||||
if ((new = NEW(char, strlen(dir) + strlen(av[0]) + 2)) != NULL) {
|
if ((new = NEW(char, strlen(dir) + strlen(av[0]) + 2)) != NULL) {
|
||||||
(void)strcpy(new, dir);
|
snprintf (new, sizeof(new),
|
||||||
(void)strcat(new, "/");
|
"%s/%s", dir, av[0]);
|
||||||
(void)strcat(new, av[0]);
|
|
||||||
rl_add_slash(new, p);
|
rl_add_slash(new, p);
|
||||||
DISPOSE(new);
|
DISPOSE(new);
|
||||||
}
|
}
|
||||||
|
@@ -23,6 +23,7 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include "editline.h"
|
#include "editline.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
RCSID("$Id$");
|
RCSID("$Id$");
|
||||||
|
|
||||||
@@ -177,10 +178,11 @@ TTYstring(unsigned char *p)
|
|||||||
TTYshow(*p++);
|
TTYshow(*p++);
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int
|
static int
|
||||||
TTYget()
|
TTYget()
|
||||||
{
|
{
|
||||||
unsigned char c;
|
char c;
|
||||||
|
int e;
|
||||||
|
|
||||||
TTYflush();
|
TTYflush();
|
||||||
if (Pushed) {
|
if (Pushed) {
|
||||||
@@ -189,7 +191,12 @@ TTYget()
|
|||||||
}
|
}
|
||||||
if (*Input)
|
if (*Input)
|
||||||
return *Input++;
|
return *Input++;
|
||||||
return read(0, &c, (size_t)1) == 1 ? c : EOF;
|
do {
|
||||||
|
e = read(0, &c, 1);
|
||||||
|
} while(e < 0 && errno == EINTR);
|
||||||
|
if(e == 1)
|
||||||
|
return c;
|
||||||
|
return EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TTYback() (backspace ? TTYputs((unsigned char *)backspace) : TTYput('\b'))
|
#define TTYback() (backspace ? TTYputs((unsigned char *)backspace) : TTYput('\b'))
|
||||||
|
@@ -53,7 +53,7 @@ extern int rl_erase;
|
|||||||
extern int rl_intr;
|
extern int rl_intr;
|
||||||
extern int rl_kill;
|
extern int rl_kill;
|
||||||
extern int rl_quit;
|
extern int rl_quit;
|
||||||
extern char *rl_complete();
|
extern char *rl_complete(char *, int *);
|
||||||
extern int rl_list_possib();
|
extern int rl_list_possib(char *, char ***);
|
||||||
extern void rl_ttyset();
|
extern void rl_ttyset(int);
|
||||||
extern void rl_add_slash();
|
extern void rl_add_slash(char *, char *);
|
||||||
|
@@ -26,6 +26,14 @@ Thu Feb 12 11:20:15 1998 Johan Danielsson <joda@emma.pdc.kth.se>
|
|||||||
|
|
||||||
* Makefile.in: Install/uninstall one library at a time.
|
* Makefile.in: Install/uninstall one library at a time.
|
||||||
|
|
||||||
|
Thu Feb 12 05:38:58 1998 Assar Westerlund <assar@sics.se>
|
||||||
|
|
||||||
|
* Makefile.in (install): one library at a time.
|
||||||
|
|
||||||
|
Mon Feb 9 23:40:32 1998 Assar Westerlund <assar@sics.se>
|
||||||
|
|
||||||
|
* common.c (find_cells): ignore empty lines
|
||||||
|
|
||||||
Tue Jan 6 04:25:58 1998 Assar Westerlund <assar@sics.se>
|
Tue Jan 6 04:25:58 1998 Assar Westerlund <assar@sics.se>
|
||||||
|
|
||||||
* afssysdefs.h (AFS_SYSCALL): add FreeBSD
|
* afssysdefs.h (AFS_SYSCALL): add FreeBSD
|
||||||
|
@@ -87,9 +87,10 @@ static char *
|
|||||||
get_realm(kafs_data *data, const char *host)
|
get_realm(kafs_data *data, const char *host)
|
||||||
{
|
{
|
||||||
char *r = krb_realmofhost(host);
|
char *r = krb_realmofhost(host);
|
||||||
if(r)
|
if(r != NULL)
|
||||||
return strdup(r);
|
return strdup(r);
|
||||||
return NULL;
|
else
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -97,6 +98,7 @@ krb_afslog_uid(const char *cell, const char *realm, uid_t uid)
|
|||||||
{
|
{
|
||||||
kafs_data kd;
|
kafs_data kd;
|
||||||
struct krb_kafs_data d;
|
struct krb_kafs_data d;
|
||||||
|
|
||||||
kd.afslog_uid = afslog_uid_int;
|
kd.afslog_uid = afslog_uid_int;
|
||||||
kd.get_cred = get_cred;
|
kd.get_cred = get_cred;
|
||||||
kd.get_realm = get_realm;
|
kd.get_realm = get_realm;
|
||||||
|
@@ -63,7 +63,7 @@ aix_setup(void)
|
|||||||
* If we are root or running setuid don't trust AFSLIBPATH!
|
* If we are root or running setuid don't trust AFSLIBPATH!
|
||||||
*/
|
*/
|
||||||
if (getuid() != 0 && !issuid() && (p = getenv("AFSLIBPATH")) != NULL)
|
if (getuid() != 0 && !issuid() && (p = getenv("AFSLIBPATH")) != NULL)
|
||||||
snprintf(path, sizeof(path), "%s", p);
|
strcpy_truncate(path, p, sizeof(path));
|
||||||
else
|
else
|
||||||
snprintf(path, sizeof(path), "%s/afslib.so", LIBDIR);
|
snprintf(path, sizeof(path), "%s/afslib.so", LIBDIR);
|
||||||
|
|
||||||
|
@@ -79,7 +79,7 @@
|
|||||||
#define AFS_SYSCALL 31
|
#define AFS_SYSCALL 31
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__)
|
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||||
#define AFS_SYSCALL 210
|
#define AFS_SYSCALL 210
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -155,8 +155,9 @@ dns_find_cell(const char *cell, char *dbserver, size_t len)
|
|||||||
struct resource_record *rr = r->head;
|
struct resource_record *rr = r->head;
|
||||||
while(rr){
|
while(rr){
|
||||||
if(rr->type == T_AFSDB && rr->u.afsdb->preference == 1){
|
if(rr->type == T_AFSDB && rr->u.afsdb->preference == 1){
|
||||||
strncpy(dbserver, rr->u.afsdb->domain, len);
|
strcpy_truncate(dbserver,
|
||||||
dbserver[len - 1] = '\0';
|
rr->u.afsdb->domain,
|
||||||
|
len);
|
||||||
ok = 0;
|
ok = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -184,7 +185,10 @@ find_cells(char *file, char ***cells, int *index)
|
|||||||
return;
|
return;
|
||||||
while (fgets(cell, sizeof(cell), f)) {
|
while (fgets(cell, sizeof(cell), f)) {
|
||||||
char *nl = strchr(cell, '\n');
|
char *nl = strchr(cell, '\n');
|
||||||
if (nl) *nl = 0;
|
if (nl)
|
||||||
|
*nl = '\0';
|
||||||
|
if (cell[0] == '\0')
|
||||||
|
continue;
|
||||||
for(i = 0; i < ind; i++)
|
for(i = 0; i < ind; i++)
|
||||||
if(strcmp((*cells)[i], cell) == 0)
|
if(strcmp((*cells)[i], cell) == 0)
|
||||||
break;
|
break;
|
||||||
|
119
lib/kafs/dlfcn.c
119
lib/kafs/dlfcn.c
@@ -115,14 +115,12 @@ void *dlopen(const char *path, int mode)
|
|||||||
}
|
}
|
||||||
if ((mp = (ModulePtr)calloc(1, sizeof(*mp))) == NULL) {
|
if ((mp = (ModulePtr)calloc(1, sizeof(*mp))) == NULL) {
|
||||||
errvalid++;
|
errvalid++;
|
||||||
strcpy(errbuf, "calloc: ");
|
snprintf (errbuf, "calloc: %s", strerror(errno));
|
||||||
strcat(errbuf, strerror(errno));
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if ((mp->name = strdup(path)) == NULL) {
|
if ((mp->name = strdup(path)) == NULL) {
|
||||||
errvalid++;
|
errvalid++;
|
||||||
strcpy(errbuf, "strdup: ");
|
snprintf (errbuf, "strdup: %s", strerror(errno));
|
||||||
strcat(errbuf, strerror(errno));
|
|
||||||
free(mp);
|
free(mp);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -134,9 +132,8 @@ void *dlopen(const char *path, int mode)
|
|||||||
free(mp->name);
|
free(mp->name);
|
||||||
free(mp);
|
free(mp);
|
||||||
errvalid++;
|
errvalid++;
|
||||||
strcpy(errbuf, "dlopen: ");
|
snprintf (errbuf, sizeof(errbuf),
|
||||||
strcat(errbuf, path);
|
"dlopen: %s: ", path);
|
||||||
strcat(errbuf, ": ");
|
|
||||||
/*
|
/*
|
||||||
* If AIX says the file is not executable, the error
|
* If AIX says the file is not executable, the error
|
||||||
* can be further described by querying the loader about
|
* can be further described by querying the loader about
|
||||||
@@ -145,14 +142,18 @@ void *dlopen(const char *path, int mode)
|
|||||||
if (errno == ENOEXEC) {
|
if (errno == ENOEXEC) {
|
||||||
char *tmp[BUFSIZ/sizeof(char *)];
|
char *tmp[BUFSIZ/sizeof(char *)];
|
||||||
if (loadquery(L_GETMESSAGES, tmp, sizeof(tmp)) == -1)
|
if (loadquery(L_GETMESSAGES, tmp, sizeof(tmp)) == -1)
|
||||||
strcpy(errbuf, strerror(errno));
|
strcpy_truncate(errbuf,
|
||||||
|
strerror(errno),
|
||||||
|
sizeof(errbuf));
|
||||||
else {
|
else {
|
||||||
char **p;
|
char **p;
|
||||||
for (p = tmp; *p; p++)
|
for (p = tmp; *p; p++)
|
||||||
caterr(*p);
|
caterr(*p);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
strcat(errbuf, strerror(errno));
|
strcat_truncate(errbuf,
|
||||||
|
strerror(errno),
|
||||||
|
sizeof(errbuf));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
mp->refCnt = 1;
|
mp->refCnt = 1;
|
||||||
@@ -161,8 +162,8 @@ void *dlopen(const char *path, int mode)
|
|||||||
if (loadbind(0, mainModule, mp->entry) == -1) {
|
if (loadbind(0, mainModule, mp->entry) == -1) {
|
||||||
dlclose(mp);
|
dlclose(mp);
|
||||||
errvalid++;
|
errvalid++;
|
||||||
strcpy(errbuf, "loadbind: ");
|
snprintf (errbuf, sizeof(errbuf),
|
||||||
strcat(errbuf, strerror(errno));
|
"loadbind: %s", strerror(errno));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@@ -175,8 +176,9 @@ void *dlopen(const char *path, int mode)
|
|||||||
if (loadbind(0, mp1->entry, mp->entry) == -1) {
|
if (loadbind(0, mp1->entry, mp->entry) == -1) {
|
||||||
dlclose(mp);
|
dlclose(mp);
|
||||||
errvalid++;
|
errvalid++;
|
||||||
strcpy(errbuf, "loadbind: ");
|
snprintf (errbuf, sizeof(errbuf),
|
||||||
strcat(errbuf, strerror(errno));
|
"loadbind: %s",
|
||||||
|
strerror(errno));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -229,29 +231,29 @@ static void caterr(char *s)
|
|||||||
p++;
|
p++;
|
||||||
switch(atoi(s)) {
|
switch(atoi(s)) {
|
||||||
case L_ERROR_TOOMANY:
|
case L_ERROR_TOOMANY:
|
||||||
strcat(errbuf, "to many errors");
|
strcat_truncate(errbuf, "to many errors", sizeof(errbuf));
|
||||||
break;
|
break;
|
||||||
case L_ERROR_NOLIB:
|
case L_ERROR_NOLIB:
|
||||||
strcat(errbuf, "can't load library");
|
strcat_truncate(errbuf, "can't load library", sizeof(errbuf));
|
||||||
strcat(errbuf, p);
|
strcat_truncate(errbuf, p, sizeof(errbuf));
|
||||||
break;
|
break;
|
||||||
case L_ERROR_UNDEF:
|
case L_ERROR_UNDEF:
|
||||||
strcat(errbuf, "can't find symbol");
|
strcat_truncate(errbuf, "can't find symbol", sizeof(errbuf));
|
||||||
strcat(errbuf, p);
|
strcat_truncate(errbuf, p, sizeof(errbuf));
|
||||||
break;
|
break;
|
||||||
case L_ERROR_RLDBAD:
|
case L_ERROR_RLDBAD:
|
||||||
strcat(errbuf, "bad RLD");
|
strcat_truncate(errbuf, "bad RLD", sizeof(errbuf));
|
||||||
strcat(errbuf, p);
|
strcat_truncate(errbuf, p, sizeof(errbuf));
|
||||||
break;
|
break;
|
||||||
case L_ERROR_FORMAT:
|
case L_ERROR_FORMAT:
|
||||||
strcat(errbuf, "bad exec format in");
|
strcat_truncate(errbuf, "bad exec format in", sizeof(errbuf));
|
||||||
strcat(errbuf, p);
|
strcat_truncate(errbuf, p, sizeof(errbuf));
|
||||||
break;
|
break;
|
||||||
case L_ERROR_ERRNO:
|
case L_ERROR_ERRNO:
|
||||||
strcat(errbuf, strerror(atoi(++p)));
|
strcat_truncate(errbuf, strerror(atoi(++p)), sizeof(errbuf));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
strcat(errbuf, s);
|
strcat_truncate(errbuf, s, sizeof(errbuf));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -270,8 +272,8 @@ void *dlsym(void *handle, const char *symbol)
|
|||||||
if (strcmp(ep->name, symbol) == 0)
|
if (strcmp(ep->name, symbol) == 0)
|
||||||
return ep->addr;
|
return ep->addr;
|
||||||
errvalid++;
|
errvalid++;
|
||||||
strcpy(errbuf, "dlsym: undefined symbol ");
|
snprintf (errbuf, sizeof(errbuf),
|
||||||
strcat(errbuf, symbol);
|
"dlsym: undefined symbol %s", symbol);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,7 +313,8 @@ int dlclose(void *handle)
|
|||||||
result = unload(mp->entry);
|
result = unload(mp->entry);
|
||||||
if (result == -1) {
|
if (result == -1) {
|
||||||
errvalid++;
|
errvalid++;
|
||||||
strcpy(errbuf, strerror(errno));
|
snprintf (errbuf, sizeof(errbuf),
|
||||||
|
"%s", strerror(errno));
|
||||||
}
|
}
|
||||||
if (mp->exports) {
|
if (mp->exports) {
|
||||||
ExportPtr ep;
|
ExportPtr ep;
|
||||||
@@ -360,8 +363,9 @@ static int readExports(ModulePtr mp)
|
|||||||
int size = 4*1024;
|
int size = 4*1024;
|
||||||
if (errno != ENOENT) {
|
if (errno != ENOENT) {
|
||||||
errvalid++;
|
errvalid++;
|
||||||
strcpy(errbuf, "readExports: ");
|
snprintf(errbuf, sizeof(errbuf),
|
||||||
strcat(errbuf, strerror(errno));
|
"readExports: %s",
|
||||||
|
strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@@ -371,8 +375,9 @@ static int readExports(ModulePtr mp)
|
|||||||
*/
|
*/
|
||||||
if ((buf = malloc(size)) == NULL) {
|
if ((buf = malloc(size)) == NULL) {
|
||||||
errvalid++;
|
errvalid++;
|
||||||
strcpy(errbuf, "readExports: ");
|
snprintf(errbuf, sizeof(errbuf),
|
||||||
strcat(errbuf, strerror(errno));
|
"readExports: %s",
|
||||||
|
strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
while ((i = loadquery(L_GETINFO, buf, size)) == -1 && errno == ENOMEM) {
|
while ((i = loadquery(L_GETINFO, buf, size)) == -1 && errno == ENOMEM) {
|
||||||
@@ -380,15 +385,17 @@ static int readExports(ModulePtr mp)
|
|||||||
size += 4*1024;
|
size += 4*1024;
|
||||||
if ((buf = malloc(size)) == NULL) {
|
if ((buf = malloc(size)) == NULL) {
|
||||||
errvalid++;
|
errvalid++;
|
||||||
strcpy(errbuf, "readExports: ");
|
snprintf(errbuf, sizeof(errbuf),
|
||||||
strcat(errbuf, strerror(errno));
|
"readExports: %s",
|
||||||
|
strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i == -1) {
|
if (i == -1) {
|
||||||
errvalid++;
|
errvalid++;
|
||||||
strcpy(errbuf, "readExports: ");
|
snprintf(errbuf, sizeof(errbuf),
|
||||||
strcat(errbuf, strerror(errno));
|
"readExports: %s",
|
||||||
|
strerror(errno));
|
||||||
free(buf);
|
free(buf);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -411,14 +418,14 @@ static int readExports(ModulePtr mp)
|
|||||||
free(buf);
|
free(buf);
|
||||||
if (!ldp) {
|
if (!ldp) {
|
||||||
errvalid++;
|
errvalid++;
|
||||||
strcpy(errbuf, "readExports: ");
|
snprintf (errbuf, sizeof(errbuf),
|
||||||
strcat(errbuf, strerror(errno));
|
"readExports: %s", strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (TYPE(ldp) != U802TOCMAGIC) {
|
if (TYPE(ldp) != U802TOCMAGIC) {
|
||||||
errvalid++;
|
errvalid++;
|
||||||
strcpy(errbuf, "readExports: bad magic");
|
snprintf(errbuf, sizeof(errbuf), "readExports: bad magic");
|
||||||
while(ldclose(ldp) == FAILURE)
|
while(ldclose(ldp) == FAILURE)
|
||||||
;
|
;
|
||||||
return -1;
|
return -1;
|
||||||
@@ -430,14 +437,16 @@ static int readExports(ModulePtr mp)
|
|||||||
*/
|
*/
|
||||||
if (ldnshread(ldp, _DATA, &shdata) != SUCCESS) {
|
if (ldnshread(ldp, _DATA, &shdata) != SUCCESS) {
|
||||||
errvalid++;
|
errvalid++;
|
||||||
strcpy(errbuf, "readExports: cannot read data section header");
|
snprintf(errbuf, sizeof(errbuf),
|
||||||
|
"readExports: cannot read data section header");
|
||||||
while(ldclose(ldp) == FAILURE)
|
while(ldclose(ldp) == FAILURE)
|
||||||
;
|
;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (ldnshread(ldp, _LOADER, &sh) != SUCCESS) {
|
if (ldnshread(ldp, _LOADER, &sh) != SUCCESS) {
|
||||||
errvalid++;
|
errvalid++;
|
||||||
strcpy(errbuf, "readExports: cannot read loader section header");
|
snprintf(errbuf, sizeof(errbuf),
|
||||||
|
"readExports: cannot read loader section header");
|
||||||
while(ldclose(ldp) == FAILURE)
|
while(ldclose(ldp) == FAILURE)
|
||||||
;
|
;
|
||||||
return -1;
|
return -1;
|
||||||
@@ -448,15 +457,16 @@ static int readExports(ModulePtr mp)
|
|||||||
*/
|
*/
|
||||||
if ((ldbuf = (char *)malloc(sh.s_size)) == NULL) {
|
if ((ldbuf = (char *)malloc(sh.s_size)) == NULL) {
|
||||||
errvalid++;
|
errvalid++;
|
||||||
strcpy(errbuf, "readExports: ");
|
snprintf (errbuf, sizeof(errbuf),
|
||||||
strcat(errbuf, strerror(errno));
|
"readExports: %s", strerror(errno));
|
||||||
while(ldclose(ldp) == FAILURE)
|
while(ldclose(ldp) == FAILURE)
|
||||||
;
|
;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (FSEEK(ldp, sh.s_scnptr, BEGINNING) != OKFSEEK) {
|
if (FSEEK(ldp, sh.s_scnptr, BEGINNING) != OKFSEEK) {
|
||||||
errvalid++;
|
errvalid++;
|
||||||
strcpy(errbuf, "readExports: cannot seek to loader section");
|
snprintf(errbuf, sizeof(errbuf),
|
||||||
|
"readExports: cannot seek to loader section");
|
||||||
free(ldbuf);
|
free(ldbuf);
|
||||||
while(ldclose(ldp) == FAILURE)
|
while(ldclose(ldp) == FAILURE)
|
||||||
;
|
;
|
||||||
@@ -464,7 +474,8 @@ static int readExports(ModulePtr mp)
|
|||||||
}
|
}
|
||||||
if (FREAD(ldbuf, sh.s_size, 1, ldp) != 1) {
|
if (FREAD(ldbuf, sh.s_size, 1, ldp) != 1) {
|
||||||
errvalid++;
|
errvalid++;
|
||||||
strcpy(errbuf, "readExports: cannot read loader section");
|
snprintf(errbuf, sizeof(errbuf),
|
||||||
|
"readExports: cannot read loader section");
|
||||||
free(ldbuf);
|
free(ldbuf);
|
||||||
while(ldclose(ldp) == FAILURE)
|
while(ldclose(ldp) == FAILURE)
|
||||||
;
|
;
|
||||||
@@ -482,8 +493,8 @@ static int readExports(ModulePtr mp)
|
|||||||
}
|
}
|
||||||
if ((mp->exports = (ExportPtr)calloc(mp->nExports, sizeof(*mp->exports))) == NULL) {
|
if ((mp->exports = (ExportPtr)calloc(mp->nExports, sizeof(*mp->exports))) == NULL) {
|
||||||
errvalid++;
|
errvalid++;
|
||||||
strcpy(errbuf, "readExports: ");
|
snprintf (errbuf, sizeof(errbuf),
|
||||||
strcat(errbuf, strerror(errno));
|
"readExports: %s", strerror(errno));
|
||||||
free(ldbuf);
|
free(ldbuf);
|
||||||
while(ldclose(ldp) == FAILURE)
|
while(ldclose(ldp) == FAILURE)
|
||||||
;
|
;
|
||||||
@@ -508,8 +519,8 @@ static int readExports(ModulePtr mp)
|
|||||||
* must copy the first SYMNMLEN chars and make
|
* must copy the first SYMNMLEN chars and make
|
||||||
* sure we have a zero byte at the end.
|
* sure we have a zero byte at the end.
|
||||||
*/
|
*/
|
||||||
strncpy(tmpsym, ls->l_name, SYMNMLEN);
|
strcpy_truncate (tmpsym, ls->l_name,
|
||||||
tmpsym[SYMNMLEN] = '\0';
|
SYMNMLEN + 1);
|
||||||
symname = tmpsym;
|
symname = tmpsym;
|
||||||
}
|
}
|
||||||
ep->name = strdup(symname);
|
ep->name = strdup(symname);
|
||||||
@@ -537,8 +548,8 @@ static void * findMain(void)
|
|||||||
|
|
||||||
if ((buf = malloc(size)) == NULL) {
|
if ((buf = malloc(size)) == NULL) {
|
||||||
errvalid++;
|
errvalid++;
|
||||||
strcpy(errbuf, "findMain: ");
|
snprintf (errbuf, sizeof(errbuf),
|
||||||
strcat(errbuf, strerror(errno));
|
"findMail: %s", strerror(errno));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
while ((i = loadquery(L_GETINFO, buf, size)) == -1 && errno == ENOMEM) {
|
while ((i = loadquery(L_GETINFO, buf, size)) == -1 && errno == ENOMEM) {
|
||||||
@@ -546,15 +557,15 @@ static void * findMain(void)
|
|||||||
size += 4*1024;
|
size += 4*1024;
|
||||||
if ((buf = malloc(size)) == NULL) {
|
if ((buf = malloc(size)) == NULL) {
|
||||||
errvalid++;
|
errvalid++;
|
||||||
strcpy(errbuf, "findMain: ");
|
snprintf (errbuf, sizeof(errbuf),
|
||||||
strcat(errbuf, strerror(errno));
|
"findMail: %s", strerror(errno));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i == -1) {
|
if (i == -1) {
|
||||||
errvalid++;
|
errvalid++;
|
||||||
strcpy(errbuf, "findMain: ");
|
snprintf (errbuf, sizeof(errbuf),
|
||||||
strcat(errbuf, strerror(errno));
|
"findMail: %s", strerror(errno));
|
||||||
free(buf);
|
free(buf);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@@ -10,6 +10,10 @@ Sun Apr 19 09:59:46 1998 Assar Westerlund <assar@sics.se>
|
|||||||
|
|
||||||
* Makefile.in: add symlink magic for linux
|
* Makefile.in: add symlink magic for linux
|
||||||
|
|
||||||
|
Sat Feb 7 07:27:18 1998 Assar Westerlund <assar@sics.se>
|
||||||
|
|
||||||
|
* otp_db.c (otp_put): make sure we don't overrun `buf'
|
||||||
|
|
||||||
Sun Nov 9 07:14:59 1997 Assar Westerlund <assar@sics.se>
|
Sun Nov 9 07:14:59 1997 Assar Westerlund <assar@sics.se>
|
||||||
|
|
||||||
* otp_locl.h: use xdbm.h
|
* otp_locl.h: use xdbm.h
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1995, 1996, 1997 Kungliga Tekniska H<>gskolan
|
* Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska H<>gskolan
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -145,8 +145,7 @@ otp_get_internal (void *v, OtpContext *ctx, int lockp)
|
|||||||
p += 4;
|
p += 4;
|
||||||
memcpy (ctx->key, p, OTPKEYSIZE);
|
memcpy (ctx->key, p, OTPKEYSIZE);
|
||||||
p += OTPKEYSIZE;
|
p += OTPKEYSIZE;
|
||||||
strncpy (ctx->seed, p, sizeof(ctx->seed));
|
strcpy_truncate (ctx->seed, p, sizeof(ctx->seed));
|
||||||
ctx->seed[sizeof(ctx->seed) - 1] = '\0';
|
|
||||||
if (lockp)
|
if (lockp)
|
||||||
return dbm_store (dbm, key, dat, DBM_REPLACE);
|
return dbm_store (dbm, key, dat, DBM_REPLACE);
|
||||||
else
|
else
|
||||||
@@ -184,15 +183,29 @@ otp_put (void *v, OtpContext *ctx)
|
|||||||
datum dat, key;
|
datum dat, key;
|
||||||
char buf[1024], *p;
|
char buf[1024], *p;
|
||||||
time_t zero = 0;
|
time_t zero = 0;
|
||||||
|
size_t len, rem;
|
||||||
|
|
||||||
key.dsize = strlen(ctx->user);
|
key.dsize = strlen(ctx->user);
|
||||||
key.dptr = ctx->user;
|
key.dptr = ctx->user;
|
||||||
|
|
||||||
p = buf;
|
p = buf;
|
||||||
|
rem = sizeof(buf);
|
||||||
|
|
||||||
|
if (rem < sizeof(zero))
|
||||||
|
return -1;
|
||||||
memcpy (p, &zero, sizeof(zero));
|
memcpy (p, &zero, sizeof(zero));
|
||||||
p += sizeof(zero);
|
p += sizeof(zero);
|
||||||
|
rem -= sizeof(zero);
|
||||||
|
len = strlen(ctx->alg->name) + 1;
|
||||||
|
|
||||||
|
if (rem < len)
|
||||||
|
return -1;
|
||||||
strcpy (p, ctx->alg->name);
|
strcpy (p, ctx->alg->name);
|
||||||
p += strlen(p) + 1;
|
p += len;
|
||||||
|
rem -= len;
|
||||||
|
|
||||||
|
if (rem < 4)
|
||||||
|
return -1;
|
||||||
{
|
{
|
||||||
unsigned char *up = (unsigned char *)p;
|
unsigned char *up = (unsigned char *)p;
|
||||||
*up++ = (ctx->n >> 24) & 0xFF;
|
*up++ = (ctx->n >> 24) & 0xFF;
|
||||||
@@ -201,10 +214,20 @@ otp_put (void *v, OtpContext *ctx)
|
|||||||
*up++ = (ctx->n >> 0) & 0xFF;
|
*up++ = (ctx->n >> 0) & 0xFF;
|
||||||
}
|
}
|
||||||
p += 4;
|
p += 4;
|
||||||
|
rem -= 4;
|
||||||
|
|
||||||
|
if (rem < OTPKEYSIZE)
|
||||||
|
return -1;
|
||||||
memcpy (p, ctx->key, OTPKEYSIZE);
|
memcpy (p, ctx->key, OTPKEYSIZE);
|
||||||
p += OTPKEYSIZE;
|
p += OTPKEYSIZE;
|
||||||
|
rem -= OTPKEYSIZE;
|
||||||
|
|
||||||
|
len = strlen(ctx->seed) + 1;
|
||||||
|
if (rem < len)
|
||||||
|
return -1;
|
||||||
strcpy (p, ctx->seed);
|
strcpy (p, ctx->seed);
|
||||||
p += strlen(p) + 1;
|
p += len;
|
||||||
|
rem -= len;
|
||||||
dat.dptr = buf;
|
dat.dptr = buf;
|
||||||
dat.dsize = p - buf;
|
dat.dsize = p - buf;
|
||||||
return dbm_store (dbm, key, dat, DBM_REPLACE);
|
return dbm_store (dbm, key, dat, DBM_REPLACE);
|
||||||
|
@@ -88,15 +88,17 @@ otp_print_hex (OtpKey key, char *str, size_t sz)
|
|||||||
void
|
void
|
||||||
otp_print_hex_extended (OtpKey key, char *str, size_t sz)
|
otp_print_hex_extended (OtpKey key, char *str, size_t sz)
|
||||||
{
|
{
|
||||||
strncpy (str, OTP_HEXPREFIX, sz);
|
strcpy_truncate (str, OTP_HEXPREFIX, sz);
|
||||||
str[sz-1] = '\0';
|
otp_print_hex (key,
|
||||||
otp_print_hex (key, str + strlen(OTP_HEXPREFIX), sz - strlen(OTP_HEXPREFIX));
|
str + strlen(OTP_HEXPREFIX),
|
||||||
|
sz - strlen(OTP_HEXPREFIX));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
otp_print_stddict_extended (OtpKey key, char *str, size_t sz)
|
otp_print_stddict_extended (OtpKey key, char *str, size_t sz)
|
||||||
{
|
{
|
||||||
strncpy (str, OTP_WORDPREFIX, sz);
|
strcpy_truncate (str, OTP_WORDPREFIX, sz);
|
||||||
str[sz-1] = '\0';
|
otp_print_stddict (key,
|
||||||
otp_print_stddict (key, str + strlen(OTP_WORDPREFIX), sz - strlen(OTP_WORDPREFIX));
|
str + strlen(OTP_WORDPREFIX),
|
||||||
|
sz - strlen(OTP_WORDPREFIX));
|
||||||
}
|
}
|
||||||
|
@@ -64,6 +64,11 @@ Thu Feb 12 03:30:08 1998 Assar Westerlund <assar@sics.se>
|
|||||||
|
|
||||||
* parse_time.c (print_time_table): don't return a void value.
|
* parse_time.c (print_time_table): don't return a void value.
|
||||||
|
|
||||||
|
Tue Feb 3 11:06:24 1998 Johan Danielsson <joda@emma.pdc.kth.se>
|
||||||
|
|
||||||
|
* getarg.c (mandoc_template): Change date format to full month
|
||||||
|
name, and day of month without leading zero.
|
||||||
|
|
||||||
Thu Jan 22 21:23:23 1998 Johan Danielsson <joda@emma.pdc.kth.se>
|
Thu Jan 22 21:23:23 1998 Johan Danielsson <joda@emma.pdc.kth.se>
|
||||||
|
|
||||||
* getarg.c: Fix long form of negative flags.
|
* getarg.c: Fix long form of negative flags.
|
||||||
|
@@ -64,7 +64,7 @@ roken_vconcat (char *s, size_t len, va_list args)
|
|||||||
|
|
||||||
if (n >= len)
|
if (n >= len)
|
||||||
return -1;
|
return -1;
|
||||||
strncpy (s, a, n);
|
memcpy (s, a, n);
|
||||||
s += n;
|
s += n;
|
||||||
len -= n;
|
len -= n;
|
||||||
}
|
}
|
||||||
@@ -82,7 +82,6 @@ roken_vmconcat (char **s, size_t max_len, va_list args)
|
|||||||
p = malloc(1);
|
p = malloc(1);
|
||||||
if(p == NULL)
|
if(p == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
*p = 0;
|
|
||||||
len = 1;
|
len = 1;
|
||||||
while ((a = va_arg(args, const char*))) {
|
while ((a = va_arg(args, const char*))) {
|
||||||
size_t n = strlen (a);
|
size_t n = strlen (a);
|
||||||
@@ -97,9 +96,10 @@ roken_vmconcat (char **s, size_t max_len, va_list args)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
p = q;
|
p = q;
|
||||||
|
memcpy (p + len - 1, a, n);
|
||||||
len += n;
|
len += n;
|
||||||
strcat(p, a);
|
|
||||||
}
|
}
|
||||||
|
p[len - 1] = '\0';
|
||||||
*s = p;
|
*s = p;
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
@@ -97,12 +97,11 @@ mandoc_template(struct getargs *args,
|
|||||||
printf(".\\\" * use better macros for arguments (like .Pa for files)\n");
|
printf(".\\\" * use better macros for arguments (like .Pa for files)\n");
|
||||||
printf(".\\\"\n");
|
printf(".\\\"\n");
|
||||||
t = time(NULL);
|
t = time(NULL);
|
||||||
strftime(timestr, sizeof(timestr), "%b %d, %Y", localtime(&t));
|
strftime(timestr, sizeof(timestr), "%B %e, %Y", localtime(&t));
|
||||||
printf(".Dd %s\n", timestr);
|
printf(".Dd %s\n", timestr);
|
||||||
p = strrchr(__progname, '/');
|
p = strrchr(__progname, '/');
|
||||||
if(p) p++; else p = __progname;
|
if(p) p++; else p = __progname;
|
||||||
strncpy(cmd, p, sizeof(cmd));
|
strcpy_truncate(cmd, p, sizeof(cmd));
|
||||||
cmd[sizeof(cmd)-1] = '\0';
|
|
||||||
strupr(cmd);
|
strupr(cmd);
|
||||||
|
|
||||||
printf(".Dt %s SECTION\n", cmd);
|
printf(".Dt %s SECTION\n", cmd);
|
||||||
|
@@ -57,6 +57,6 @@ getcwd(char *path, size_t size)
|
|||||||
char *ret;
|
char *ret;
|
||||||
ret = getwd(xxx);
|
ret = getwd(xxx);
|
||||||
if(ret)
|
if(ret)
|
||||||
strncpy(path, xxx, size);
|
strcpy_truncate(path, xxx, size);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@@ -65,13 +65,11 @@ gethostname(char *name, int namelen)
|
|||||||
ret = uname (&utsname);
|
ret = uname (&utsname);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
strncpy (name, utsname.nodename, namelen);
|
strcpy_truncate (name, utsname.nodename, namelen);
|
||||||
name[namelen-1] = '\0';
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
strncpy (name, "some.random.host", namelen);
|
strcpy_truncate (name, "some.random.host", namelen);
|
||||||
name[namelen-1] = '\0';
|
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -748,7 +748,7 @@ g_opendir(Char *str, glob_t *pglob)
|
|||||||
char buf[MaxPathLen];
|
char buf[MaxPathLen];
|
||||||
|
|
||||||
if (!*str)
|
if (!*str)
|
||||||
strcpy(buf, ".");
|
strcpy_truncate(buf, ".", sizeof(buf));
|
||||||
else
|
else
|
||||||
g_Ctoc(str, buf);
|
g_Ctoc(str, buf);
|
||||||
|
|
||||||
|
@@ -84,12 +84,10 @@ inaddr2str(struct in_addr addr, char *s, size_t len)
|
|||||||
if(h)
|
if(h)
|
||||||
while ((p = *(h->h_addr_list)++))
|
while ((p = *(h->h_addr_list)++))
|
||||||
if (memcmp (p, &addr, sizeof(addr)) == 0) {
|
if (memcmp (p, &addr, sizeof(addr)) == 0) {
|
||||||
strncpy (s, h->h_name, len);
|
strcpy_truncate (s, h->h_name, len);
|
||||||
s[len - 1] = '\0';
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
strncpy (s, inet_ntoa (addr), len);
|
strcpy_truncate (s, inet_ntoa (addr), len);
|
||||||
s[len - 1] = '\0';
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -127,8 +127,7 @@ __ivaliduser(FILE *hostf, unsigned raddr, const char *luser,
|
|||||||
sizeof(u_long),
|
sizeof(u_long),
|
||||||
AF_INET)) == NULL)
|
AF_INET)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
strncpy(hname, hp->h_name, sizeof(hname));
|
strcpy_truncate(hname, hp->h_name, sizeof(hname));
|
||||||
hname[sizeof(hname) - 1] = '\0';
|
|
||||||
|
|
||||||
while (fgets(buf, sizeof(buf), hostf)) {
|
while (fgets(buf, sizeof(buf), hostf)) {
|
||||||
p = buf;
|
p = buf;
|
||||||
@@ -257,8 +256,7 @@ again:
|
|||||||
first = 0;
|
first = 0;
|
||||||
if ((pwd = k_getpwnam((char*)luser)) == NULL)
|
if ((pwd = k_getpwnam((char*)luser)) == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
strcpy(pbuf, pwd->pw_dir);
|
snprintf (pbuf, sizeof(pbuf), "%s/.rhosts", pwd->pw_dir);
|
||||||
strcat(pbuf, "/.rhosts");
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Change effective uid while opening .rhosts. If root and
|
* Change effective uid while opening .rhosts. If root and
|
||||||
|
@@ -193,6 +193,14 @@ char *strtok_r(char *s1, const char *s2, char **lasts);
|
|||||||
char * strupr(char *);
|
char * strupr(char *);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_STRCPY_TRUNCATE
|
||||||
|
int strcpy_truncate (char *dst, const char *src, size_t dst_sz);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_STRCAT_TRUNCATE
|
||||||
|
int strcat_truncate (char *dst, const char *src, size_t dst_sz);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_GETDTABLESIZE
|
#ifndef HAVE_GETDTABLESIZE
|
||||||
int getdtablesize(void);
|
int getdtablesize(void);
|
||||||
#endif
|
#endif
|
||||||
|
@@ -70,6 +70,7 @@ struct state {
|
|||||||
/* XXX - methods */
|
/* XXX - methods */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef HAVE_VSNPRINTF
|
||||||
static int
|
static int
|
||||||
sn_reserve (struct state *state, size_t n)
|
sn_reserve (struct state *state, size_t n)
|
||||||
{
|
{
|
||||||
@@ -86,6 +87,7 @@ sn_append_char (struct state *state, char c)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int
|
static int
|
||||||
as_reserve (struct state *state, size_t n)
|
as_reserve (struct state *state, size_t n)
|
||||||
|
@@ -43,6 +43,8 @@
|
|||||||
|
|
||||||
RCSID("$Id$");
|
RCSID("$Id$");
|
||||||
|
|
||||||
|
#ifndef HAVE_STRCPY_TRUNCATE
|
||||||
|
|
||||||
int
|
int
|
||||||
strcpy_truncate (char *dst, const char *src, size_t dst_sz)
|
strcpy_truncate (char *dst, const char *src, size_t dst_sz)
|
||||||
{
|
{
|
||||||
@@ -59,3 +61,5 @@ strcpy_truncate (char *dst, const char *src, size_t dst_sz)
|
|||||||
else
|
else
|
||||||
return dst_sz;
|
return dst_sz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1995, 1996, 1997 Kungliga Tekniska H<>gskolan
|
* Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska H<>gskolan
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -56,7 +56,7 @@ strerror(int eno)
|
|||||||
if(eno < 0 || eno >= sys_nerr)
|
if(eno < 0 || eno >= sys_nerr)
|
||||||
snprintf(emsg, sizeof(emsg), "Error %d occurred.", eno);
|
snprintf(emsg, sizeof(emsg), "Error %d occurred.", eno);
|
||||||
else
|
else
|
||||||
strcpy(emsg, sys_errlist[eno]);
|
snprintf(emsg, sizeof(emsg), "%s", sys_errlist[eno]);
|
||||||
|
|
||||||
return emsg;
|
return emsg;
|
||||||
}
|
}
|
||||||
|
@@ -43,6 +43,8 @@
|
|||||||
|
|
||||||
RCSID("$Id$");
|
RCSID("$Id$");
|
||||||
|
|
||||||
|
#ifndef HAVE_STRCPY_TRUNCATE
|
||||||
|
|
||||||
int
|
int
|
||||||
strcpy_truncate (char *dst, const char *src, size_t dst_sz)
|
strcpy_truncate (char *dst, const char *src, size_t dst_sz)
|
||||||
{
|
{
|
||||||
@@ -59,3 +61,5 @@ strcpy_truncate (char *dst, const char *src, size_t dst_sz)
|
|||||||
else
|
else
|
||||||
return dst_sz;
|
return dst_sz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@@ -51,6 +51,10 @@ Sun Feb 15 05:12:11 1998 Johan Danielsson <joda@emma.pdc.kth.se>
|
|||||||
|
|
||||||
* sl.c: Move command line split to function `sl_make_argv'.
|
* sl.c: Move command line split to function `sl_make_argv'.
|
||||||
|
|
||||||
|
Tue Feb 3 16:45:44 1998 Johan Danielsson <joda@emma.pdc.kth.se>
|
||||||
|
|
||||||
|
* sl.c: Add sl_command_loop, that is the loop body of sl_loop.
|
||||||
|
|
||||||
Mon Oct 20 01:13:21 1997 Assar Westerlund <assar@sics.se>
|
Mon Oct 20 01:13:21 1997 Assar Westerlund <assar@sics.se>
|
||||||
|
|
||||||
* sl.c (sl_help): actually use the `help' field of `SL_cmd'
|
* sl.c (sl_help): actually use the `help' field of `SL_cmd'
|
||||||
|
67
lib/sl/sl.c
67
lib/sl/sl.c
@@ -143,6 +143,11 @@ sl_command(SL_cmd *cmds, int argc, char **argv)
|
|||||||
return (*c->func)(argc, argv);
|
return (*c->func)(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct sl_data {
|
||||||
|
int max_count;
|
||||||
|
char **ptr;
|
||||||
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
sl_make_argv(char *line, int *ret_argc, char ***ret_argv)
|
sl_make_argv(char *line, int *ret_argc, char ***ret_argv)
|
||||||
{
|
{
|
||||||
@@ -178,39 +183,47 @@ sl_make_argv(char *line, int *ret_argc, char ***ret_argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* return values: 0 on success, -1 on fatal error, or return value of command */
|
||||||
int
|
int
|
||||||
sl_loop (SL_cmd *cmds, char *prompt)
|
sl_command_loop(SL_cmd *cmds, char *prompt, void **data)
|
||||||
{
|
{
|
||||||
|
int ret = 0;
|
||||||
char *buf;
|
char *buf;
|
||||||
|
SL_cmd *c;
|
||||||
int argc;
|
int argc;
|
||||||
char **argv;
|
char **argv;
|
||||||
int ret = 0;
|
|
||||||
|
ret = 0;
|
||||||
|
buf = readline(prompt);
|
||||||
|
if(buf == NULL)
|
||||||
|
return 1;
|
||||||
|
|
||||||
while(ret == 0) {
|
if(*buf)
|
||||||
ret = 0;
|
add_history(buf);
|
||||||
/* XXX should make sure this doesn't do funny things if stdin
|
ret = sl_make_argv(buf, &argc, &argv);
|
||||||
is not a tty */
|
if(ret) {
|
||||||
buf = readline(prompt);
|
fprintf(stderr, "sl_loop: out of memory\n");
|
||||||
if(buf == NULL)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if(*buf)
|
|
||||||
add_history(buf);
|
|
||||||
argc = 0;
|
|
||||||
ret = sl_make_argv(buf, &argc, &argv);
|
|
||||||
if(ret) {
|
|
||||||
fprintf(stderr, "sl_loop: out of memory\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if(argc >= 1) {
|
|
||||||
ret = sl_command(cmds, argc, argv);
|
|
||||||
if(ret == -1) {
|
|
||||||
printf ("Unrecognized command: %s\n", argv[0]);
|
|
||||||
ret = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
free(argv);
|
|
||||||
free(buf);
|
free(buf);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
if (argc >= 1) {
|
||||||
|
ret = sl_command(cmds, argc, argv);
|
||||||
|
if(ret == -1) {
|
||||||
|
printf ("Unrecognized command: %s\n", argv[0]);
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(buf);
|
||||||
|
free(argv);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
sl_loop(SL_cmd *cmds, char *prompt)
|
||||||
|
{
|
||||||
|
void *data = NULL;
|
||||||
|
int ret;
|
||||||
|
while((ret = sl_command_loop(cmds, prompt, &data)) == 0)
|
||||||
|
;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
@@ -54,6 +54,7 @@ typedef struct sl_cmd SL_cmd;
|
|||||||
|
|
||||||
void sl_help (SL_cmd *, int argc, char **argv);
|
void sl_help (SL_cmd *, int argc, char **argv);
|
||||||
int sl_loop (SL_cmd *, char *prompt);
|
int sl_loop (SL_cmd *, char *prompt);
|
||||||
|
int sl_command_loop (SL_cmd *cmds, char *prompt, void **data);
|
||||||
int sl_command (SL_cmd *cmds, int argc, char **argv);
|
int sl_command (SL_cmd *cmds, int argc, char **argv);
|
||||||
int sl_make_argv(char*, int*, char***);
|
int sl_make_argv(char*, int*, char***);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user