Remove obsolete files on the vendor branch.
This commit is contained in:
parent
d95e11bf7e
commit
8cf8104b8f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/vendor-crypto/openssh/dist/; revision=124243
@ -1,368 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1999 Dug Song. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
RCSID("$OpenBSD: auth-krb4.c,v 1.29 2003/02/21 10:34:48 mpech Exp $");
|
||||
|
||||
#include "ssh.h"
|
||||
#include "ssh1.h"
|
||||
#include "packet.h"
|
||||
#include "xmalloc.h"
|
||||
#include "log.h"
|
||||
#include "servconf.h"
|
||||
#include "uidswap.h"
|
||||
#include "auth.h"
|
||||
|
||||
#ifdef AFS
|
||||
#include "radix.h"
|
||||
#endif
|
||||
|
||||
#ifdef KRB4
|
||||
extern ServerOptions options;
|
||||
|
||||
static int
|
||||
krb4_init(void *context)
|
||||
{
|
||||
static int cleanup_registered = 0;
|
||||
Authctxt *authctxt = (Authctxt *)context;
|
||||
const char *tkt_root = TKT_ROOT;
|
||||
struct stat st;
|
||||
int fd;
|
||||
|
||||
if (!authctxt->krb4_ticket_file) {
|
||||
/* Set unique ticket string manually since we're still root. */
|
||||
authctxt->krb4_ticket_file = xmalloc(MAXPATHLEN);
|
||||
#ifdef AFS
|
||||
if (lstat("/ticket", &st) != -1)
|
||||
tkt_root = "/ticket/";
|
||||
#endif /* AFS */
|
||||
snprintf(authctxt->krb4_ticket_file, MAXPATHLEN, "%s%u_%ld",
|
||||
tkt_root, authctxt->pw->pw_uid, (long)getpid());
|
||||
krb_set_tkt_string(authctxt->krb4_ticket_file);
|
||||
}
|
||||
/* Register ticket cleanup in case of fatal error. */
|
||||
if (!cleanup_registered) {
|
||||
fatal_add_cleanup(krb4_cleanup_proc, authctxt);
|
||||
cleanup_registered = 1;
|
||||
}
|
||||
/* Try to create our ticket file. */
|
||||
if ((fd = mkstemp(authctxt->krb4_ticket_file)) != -1) {
|
||||
close(fd);
|
||||
return (1);
|
||||
}
|
||||
/* Ticket file exists - make sure user owns it (just passed ticket). */
|
||||
if (lstat(authctxt->krb4_ticket_file, &st) != -1) {
|
||||
if (st.st_mode == (S_IFREG | S_IRUSR | S_IWUSR) &&
|
||||
st.st_uid == authctxt->pw->pw_uid)
|
||||
return (1);
|
||||
}
|
||||
/* Failure - cancel cleanup function, leaving ticket for inspection. */
|
||||
log("WARNING: bad ticket file %s", authctxt->krb4_ticket_file);
|
||||
|
||||
fatal_remove_cleanup(krb4_cleanup_proc, authctxt);
|
||||
cleanup_registered = 0;
|
||||
|
||||
xfree(authctxt->krb4_ticket_file);
|
||||
authctxt->krb4_ticket_file = NULL;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* try krb4 authentication,
|
||||
* return 1 on success, 0 on failure, -1 if krb4 is not available
|
||||
*/
|
||||
int
|
||||
auth_krb4_password(Authctxt *authctxt, const char *password)
|
||||
{
|
||||
AUTH_DAT adata;
|
||||
KTEXT_ST tkt;
|
||||
struct hostent *hp;
|
||||
struct passwd *pw;
|
||||
char localhost[MAXHOSTNAMELEN], phost[INST_SZ], realm[REALM_SZ];
|
||||
u_int32_t faddr;
|
||||
int r;
|
||||
|
||||
if ((pw = authctxt->pw) == NULL)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Try Kerberos password authentication only for non-root
|
||||
* users and only if Kerberos is installed.
|
||||
*/
|
||||
if (pw->pw_uid != 0 && krb_get_lrealm(realm, 1) == KSUCCESS) {
|
||||
/* Set up our ticket file. */
|
||||
if (!krb4_init(authctxt)) {
|
||||
log("Couldn't initialize Kerberos ticket file for %s!",
|
||||
pw->pw_name);
|
||||
goto failure;
|
||||
}
|
||||
/* Try to get TGT using our password. */
|
||||
r = krb_get_pw_in_tkt((char *) pw->pw_name, "", realm,
|
||||
"krbtgt", realm, DEFAULT_TKT_LIFE, (char *)password);
|
||||
if (r != INTK_OK) {
|
||||
debug("Kerberos v4 password authentication for %s "
|
||||
"failed: %s", pw->pw_name, krb_err_txt[r]);
|
||||
goto failure;
|
||||
}
|
||||
/* Successful authentication. */
|
||||
chown(tkt_string(), pw->pw_uid, pw->pw_gid);
|
||||
|
||||
/*
|
||||
* Now that we have a TGT, try to get a local
|
||||
* "rcmd" ticket to ensure that we are not talking
|
||||
* to a bogus Kerberos server.
|
||||
*/
|
||||
gethostname(localhost, sizeof(localhost));
|
||||
strlcpy(phost, (char *)krb_get_phost(localhost),
|
||||
sizeof(phost));
|
||||
r = krb_mk_req(&tkt, KRB4_SERVICE_NAME, phost, realm, 33);
|
||||
|
||||
if (r == KSUCCESS) {
|
||||
if ((hp = gethostbyname(localhost)) == NULL) {
|
||||
log("Couldn't get local host address!");
|
||||
goto failure;
|
||||
}
|
||||
memmove((void *)&faddr, (void *)hp->h_addr,
|
||||
sizeof(faddr));
|
||||
|
||||
/* Verify our "rcmd" ticket. */
|
||||
r = krb_rd_req(&tkt, KRB4_SERVICE_NAME, phost,
|
||||
faddr, &adata, "");
|
||||
if (r == RD_AP_UNDEC) {
|
||||
/*
|
||||
* Probably didn't have a srvtab on
|
||||
* localhost. Disallow login.
|
||||
*/
|
||||
log("Kerberos v4 TGT for %s unverifiable, "
|
||||
"no srvtab installed? krb_rd_req: %s",
|
||||
pw->pw_name, krb_err_txt[r]);
|
||||
goto failure;
|
||||
} else if (r != KSUCCESS) {
|
||||
log("Kerberos v4 %s ticket unverifiable: %s",
|
||||
KRB4_SERVICE_NAME, krb_err_txt[r]);
|
||||
goto failure;
|
||||
}
|
||||
} else if (r == KDC_PR_UNKNOWN) {
|
||||
/*
|
||||
* Disallow login if no rcmd service exists, and
|
||||
* log the error.
|
||||
*/
|
||||
log("Kerberos v4 TGT for %s unverifiable: %s; %s.%s "
|
||||
"not registered, or srvtab is wrong?", pw->pw_name,
|
||||
krb_err_txt[r], KRB4_SERVICE_NAME, phost);
|
||||
goto failure;
|
||||
} else {
|
||||
/*
|
||||
* TGT is bad, forget it. Possibly spoofed!
|
||||
*/
|
||||
debug("WARNING: Kerberos v4 TGT possibly spoofed "
|
||||
"for %s: %s", pw->pw_name, krb_err_txt[r]);
|
||||
goto failure;
|
||||
}
|
||||
/* Authentication succeeded. */
|
||||
return (1);
|
||||
} else
|
||||
/* Logging in as root or no local Kerberos realm. */
|
||||
debug("Unable to authenticate to Kerberos.");
|
||||
|
||||
failure:
|
||||
krb4_cleanup_proc(authctxt);
|
||||
|
||||
if (!options.kerberos_or_local_passwd)
|
||||
return (0);
|
||||
|
||||
/* Fall back to ordinary passwd authentication. */
|
||||
return (-1);
|
||||
}
|
||||
|
||||
void
|
||||
krb4_cleanup_proc(void *context)
|
||||
{
|
||||
Authctxt *authctxt = (Authctxt *)context;
|
||||
debug("krb4_cleanup_proc called");
|
||||
if (authctxt->krb4_ticket_file) {
|
||||
(void) dest_tkt();
|
||||
xfree(authctxt->krb4_ticket_file);
|
||||
authctxt->krb4_ticket_file = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
auth_krb4(Authctxt *authctxt, KTEXT auth, char **client, KTEXT reply)
|
||||
{
|
||||
AUTH_DAT adat = {0};
|
||||
Key_schedule schedule;
|
||||
struct sockaddr_in local, foreign;
|
||||
char instance[INST_SZ];
|
||||
socklen_t slen;
|
||||
u_int cksum;
|
||||
int r, s;
|
||||
|
||||
s = packet_get_connection_in();
|
||||
|
||||
slen = sizeof(local);
|
||||
memset(&local, 0, sizeof(local));
|
||||
if (getsockname(s, (struct sockaddr *) & local, &slen) < 0)
|
||||
debug("getsockname failed: %.100s", strerror(errno));
|
||||
slen = sizeof(foreign);
|
||||
memset(&foreign, 0, sizeof(foreign));
|
||||
if (getpeername(s, (struct sockaddr *) & foreign, &slen) < 0) {
|
||||
debug("getpeername failed: %.100s", strerror(errno));
|
||||
fatal_cleanup();
|
||||
}
|
||||
instance[0] = '*';
|
||||
instance[1] = 0;
|
||||
|
||||
/* Get the encrypted request, challenge, and session key. */
|
||||
if ((r = krb_rd_req(auth, KRB4_SERVICE_NAME, instance,
|
||||
0, &adat, ""))) {
|
||||
debug("Kerberos v4 krb_rd_req: %.100s", krb_err_txt[r]);
|
||||
return (0);
|
||||
}
|
||||
des_key_sched((des_cblock *) adat.session, schedule);
|
||||
|
||||
*client = xmalloc(MAX_K_NAME_SZ);
|
||||
(void) snprintf(*client, MAX_K_NAME_SZ, "%s%s%s@%s", adat.pname,
|
||||
*adat.pinst ? "." : "", adat.pinst, adat.prealm);
|
||||
|
||||
/* Check ~/.klogin authorization now. */
|
||||
if (kuserok(&adat, authctxt->user) != KSUCCESS) {
|
||||
log("Kerberos v4 .klogin authorization failed for %s to "
|
||||
"account %s", *client, authctxt->user);
|
||||
xfree(*client);
|
||||
*client = NULL;
|
||||
return (0);
|
||||
}
|
||||
/* Increment the checksum, and return it encrypted with the
|
||||
session key. */
|
||||
cksum = adat.checksum + 1;
|
||||
cksum = htonl(cksum);
|
||||
|
||||
/* If we can't successfully encrypt the checksum, we send back an
|
||||
empty message, admitting our failure. */
|
||||
if ((r = krb_mk_priv((u_char *) & cksum, reply->dat, sizeof(cksum) + 1,
|
||||
schedule, &adat.session, &local, &foreign)) < 0) {
|
||||
debug("Kerberos v4 mk_priv: (%d) %s", r, krb_err_txt[r]);
|
||||
reply->dat[0] = 0;
|
||||
reply->length = 0;
|
||||
} else
|
||||
reply->length = r;
|
||||
|
||||
/* Clear session key. */
|
||||
memset(&adat.session, 0, sizeof(adat.session));
|
||||
return (1);
|
||||
}
|
||||
#endif /* KRB4 */
|
||||
|
||||
#ifdef AFS
|
||||
int
|
||||
auth_krb4_tgt(Authctxt *authctxt, const char *string)
|
||||
{
|
||||
CREDENTIALS creds;
|
||||
struct passwd *pw;
|
||||
|
||||
if ((pw = authctxt->pw) == NULL)
|
||||
goto failure;
|
||||
|
||||
temporarily_use_uid(pw);
|
||||
|
||||
if (!radix_to_creds(string, &creds)) {
|
||||
log("Protocol error decoding Kerberos v4 TGT");
|
||||
goto failure;
|
||||
}
|
||||
if (strncmp(creds.service, "", 1) == 0) /* backward compatibility */
|
||||
strlcpy(creds.service, "krbtgt", sizeof creds.service);
|
||||
|
||||
if (strcmp(creds.service, "krbtgt")) {
|
||||
log("Kerberos v4 TGT (%s%s%s@%s) rejected for %s",
|
||||
creds.pname, creds.pinst[0] ? "." : "", creds.pinst,
|
||||
creds.realm, pw->pw_name);
|
||||
goto failure;
|
||||
}
|
||||
if (!krb4_init(authctxt))
|
||||
goto failure;
|
||||
|
||||
if (in_tkt(creds.pname, creds.pinst) != KSUCCESS)
|
||||
goto failure;
|
||||
|
||||
if (save_credentials(creds.service, creds.instance, creds.realm,
|
||||
creds.session, creds.lifetime, creds.kvno, &creds.ticket_st,
|
||||
creds.issue_date) != KSUCCESS) {
|
||||
debug("Kerberos v4 TGT refused: couldn't save credentials");
|
||||
goto failure;
|
||||
}
|
||||
/* Successful authentication, passed all checks. */
|
||||
chown(tkt_string(), pw->pw_uid, pw->pw_gid);
|
||||
|
||||
debug("Kerberos v4 TGT accepted (%s%s%s@%s)",
|
||||
creds.pname, creds.pinst[0] ? "." : "", creds.pinst, creds.realm);
|
||||
memset(&creds, 0, sizeof(creds));
|
||||
|
||||
restore_uid();
|
||||
|
||||
return (1);
|
||||
|
||||
failure:
|
||||
krb4_cleanup_proc(authctxt);
|
||||
memset(&creds, 0, sizeof(creds));
|
||||
restore_uid();
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
auth_afs_token(Authctxt *authctxt, const char *token_string)
|
||||
{
|
||||
CREDENTIALS creds;
|
||||
struct passwd *pw;
|
||||
uid_t uid;
|
||||
|
||||
if ((pw = authctxt->pw) == NULL)
|
||||
return (0);
|
||||
|
||||
if (!radix_to_creds(token_string, &creds)) {
|
||||
log("Protocol error decoding AFS token");
|
||||
return (0);
|
||||
}
|
||||
if (strncmp(creds.service, "", 1) == 0) /* backward compatibility */
|
||||
strlcpy(creds.service, "afs", sizeof creds.service);
|
||||
|
||||
if (strncmp(creds.pname, "AFS ID ", 7) == 0)
|
||||
uid = atoi(creds.pname + 7);
|
||||
else
|
||||
uid = pw->pw_uid;
|
||||
|
||||
if (kafs_settoken(creds.realm, uid, &creds)) {
|
||||
log("AFS token (%s@%s) rejected for %s",
|
||||
creds.pname, creds.realm, pw->pw_name);
|
||||
memset(&creds, 0, sizeof(creds));
|
||||
return (0);
|
||||
}
|
||||
debug("AFS token accepted (%s@%s)", creds.pname, creds.realm);
|
||||
memset(&creds, 0, sizeof(creds));
|
||||
|
||||
return (1);
|
||||
}
|
||||
#endif /* AFS */
|
@ -1,165 +0,0 @@
|
||||
#include "includes.h"
|
||||
RCSID("$Id: auth2-pam.c,v 1.15 2003/01/08 01:37:03 djm Exp $");
|
||||
|
||||
#ifdef USE_PAM
|
||||
#include <security/pam_appl.h>
|
||||
|
||||
#include "ssh.h"
|
||||
#include "ssh2.h"
|
||||
#include "auth.h"
|
||||
#include "auth-pam.h"
|
||||
#include "packet.h"
|
||||
#include "xmalloc.h"
|
||||
#include "dispatch.h"
|
||||
#include "log.h"
|
||||
|
||||
static int do_pam_conversation_kbd_int(int num_msg,
|
||||
const struct pam_message **msg, struct pam_response **resp,
|
||||
void *appdata_ptr);
|
||||
void input_userauth_info_response_pam(int type, u_int32_t seqnr, void *ctxt);
|
||||
|
||||
struct {
|
||||
int finished, num_received, num_expected;
|
||||
int *prompts;
|
||||
struct pam_response *responses;
|
||||
} context_pam2 = {0, 0, 0, NULL};
|
||||
|
||||
static struct pam_conv conv2 = {
|
||||
do_pam_conversation_kbd_int,
|
||||
NULL,
|
||||
};
|
||||
|
||||
int
|
||||
auth2_pam(Authctxt *authctxt)
|
||||
{
|
||||
int retval = -1;
|
||||
|
||||
if (authctxt->user == NULL)
|
||||
fatal("auth2_pam: internal error: no user");
|
||||
|
||||
conv2.appdata_ptr = authctxt;
|
||||
do_pam_set_conv(&conv2);
|
||||
|
||||
dispatch_set(SSH2_MSG_USERAUTH_INFO_RESPONSE,
|
||||
&input_userauth_info_response_pam);
|
||||
retval = (do_pam_authenticate(0) == PAM_SUCCESS);
|
||||
dispatch_set(SSH2_MSG_USERAUTH_INFO_RESPONSE, NULL);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int
|
||||
do_pam_conversation_kbd_int(int num_msg, const struct pam_message **msg,
|
||||
struct pam_response **resp, void *appdata_ptr)
|
||||
{
|
||||
int i, j, done;
|
||||
char *text;
|
||||
|
||||
context_pam2.finished = 0;
|
||||
context_pam2.num_received = 0;
|
||||
context_pam2.num_expected = 0;
|
||||
context_pam2.prompts = xmalloc(sizeof(int) * num_msg);
|
||||
context_pam2.responses = xmalloc(sizeof(struct pam_response) * num_msg);
|
||||
memset(context_pam2.responses, 0, sizeof(struct pam_response) * num_msg);
|
||||
|
||||
text = NULL;
|
||||
for (i = 0, context_pam2.num_expected = 0; i < num_msg; i++) {
|
||||
int style = PAM_MSG_MEMBER(msg, i, msg_style);
|
||||
switch (style) {
|
||||
case PAM_PROMPT_ECHO_ON:
|
||||
case PAM_PROMPT_ECHO_OFF:
|
||||
context_pam2.num_expected++;
|
||||
break;
|
||||
case PAM_TEXT_INFO:
|
||||
case PAM_ERROR_MSG:
|
||||
default:
|
||||
/* Capture all these messages to be sent at once */
|
||||
message_cat(&text, PAM_MSG_MEMBER(msg, i, msg));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (context_pam2.num_expected == 0)
|
||||
return PAM_SUCCESS;
|
||||
|
||||
packet_start(SSH2_MSG_USERAUTH_INFO_REQUEST);
|
||||
packet_put_cstring(""); /* Name */
|
||||
packet_put_cstring(""); /* Instructions */
|
||||
packet_put_cstring(""); /* Language */
|
||||
packet_put_int(context_pam2.num_expected);
|
||||
|
||||
for (i = 0, j = 0; i < num_msg; i++) {
|
||||
int style = PAM_MSG_MEMBER(msg, i, msg_style);
|
||||
|
||||
/* Skip messages which don't need a reply */
|
||||
if (style != PAM_PROMPT_ECHO_ON && style != PAM_PROMPT_ECHO_OFF)
|
||||
continue;
|
||||
|
||||
context_pam2.prompts[j++] = i;
|
||||
if (text) {
|
||||
message_cat(&text, PAM_MSG_MEMBER(msg, i, msg));
|
||||
packet_put_cstring(text);
|
||||
text = NULL;
|
||||
} else
|
||||
packet_put_cstring(PAM_MSG_MEMBER(msg, i, msg));
|
||||
packet_put_char(style == PAM_PROMPT_ECHO_ON);
|
||||
}
|
||||
packet_send();
|
||||
packet_write_wait();
|
||||
|
||||
/*
|
||||
* Grabbing control of execution and spinning until we get what
|
||||
* we want is probably rude, but it seems to work properly, and
|
||||
* the client *should* be in lock-step with us, so the loop should
|
||||
* only be traversed once.
|
||||
*/
|
||||
while(context_pam2.finished == 0) {
|
||||
done = 1;
|
||||
dispatch_run(DISPATCH_BLOCK, &done, appdata_ptr);
|
||||
if (context_pam2.finished == 0)
|
||||
debug("extra packet during conversation");
|
||||
}
|
||||
|
||||
if (context_pam2.num_received == context_pam2.num_expected) {
|
||||
*resp = context_pam2.responses;
|
||||
return PAM_SUCCESS;
|
||||
} else
|
||||
return PAM_CONV_ERR;
|
||||
}
|
||||
|
||||
void
|
||||
input_userauth_info_response_pam(int type, u_int32_t seqnr, void *ctxt)
|
||||
{
|
||||
Authctxt *authctxt = ctxt;
|
||||
unsigned int nresp = 0, rlen = 0, i = 0;
|
||||
char *resp;
|
||||
|
||||
if (authctxt == NULL)
|
||||
fatal("input_userauth_info_response_pam: no authentication context");
|
||||
|
||||
nresp = packet_get_int(); /* Number of responses. */
|
||||
debug("got %d responses", nresp);
|
||||
|
||||
|
||||
if (nresp != context_pam2.num_expected)
|
||||
fatal("%s: Received incorrect number of responses "
|
||||
"(expected %d, received %u)", __func__,
|
||||
context_pam2.num_expected, nresp);
|
||||
|
||||
if (nresp > 100)
|
||||
fatal("%s: too many replies", __func__);
|
||||
|
||||
for (i = 0; i < nresp; i++) {
|
||||
int j = context_pam2.prompts[i];
|
||||
|
||||
resp = packet_get_string(&rlen);
|
||||
context_pam2.responses[j].resp_retcode = PAM_SUCCESS;
|
||||
context_pam2.responses[j].resp = resp;
|
||||
context_pam2.num_received++;
|
||||
}
|
||||
|
||||
context_pam2.finished = 1;
|
||||
|
||||
packet_check_eom();
|
||||
}
|
||||
#endif
|
@ -1,8 +0,0 @@
|
||||
/* $Id: auth2-pam.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */
|
||||
|
||||
#include "includes.h"
|
||||
#ifdef USE_PAM
|
||||
|
||||
int auth2_pam(Authctxt *authctxt);
|
||||
|
||||
#endif /* USE_PAM */
|
@ -1,592 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
###
|
||||
### Quick usage: mdoc2man.pl < mdoc_manpage.8 > man_manpage.8
|
||||
###
|
||||
###
|
||||
### Copyright (c) 2001 University of Illinois Board of Trustees
|
||||
### Copyright (c) 2001 Mark D. Roth
|
||||
### All rights reserved.
|
||||
###
|
||||
### Redistribution and use in source and binary forms, with or without
|
||||
### modification, are permitted provided that the following conditions
|
||||
### are met:
|
||||
### 1. Redistributions of source code must retain the above copyright
|
||||
### notice, this list of conditions and the following disclaimer.
|
||||
### 2. Redistributions in binary form must reproduce the above copyright
|
||||
### notice, this list of conditions and the following disclaimer in the
|
||||
### documentation and/or other materials provided with the distribution.
|
||||
### 3. All advertising materials mentioning features or use of this software
|
||||
### must display the following acknowledgement:
|
||||
### This product includes software developed by the University of
|
||||
### Illinois at Urbana, and their contributors.
|
||||
### 4. The University nor the names of their
|
||||
### contributors may be used to endorse or promote products derived from
|
||||
### this software without specific prior written permission.
|
||||
###
|
||||
### THIS SOFTWARE IS PROVIDED BY THE TRUSTEES AND CONTRIBUTORS ``AS IS'' AND
|
||||
### ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
### IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
### ARE DISCLAIMED. IN NO EVENT SHALL THE TRUSTEES OR CONTRIBUTORS BE LIABLE
|
||||
### FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
### DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
### OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
### HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
### LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
### OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
### SUCH DAMAGE.
|
||||
###
|
||||
|
||||
use strict;
|
||||
|
||||
my ($name, $date, $id);
|
||||
my ($line);
|
||||
my ($optlist, $oldoptlist, $nospace, $enum, $synopsis);
|
||||
my ($reference, $block, $ext, $extopt, $literal);
|
||||
my (@refauthors, $reftitle, $refissue, $refdate, $refopt);
|
||||
|
||||
|
||||
$optlist = 0; ### 1 = bullet, 2 = enum, 3 = tag, 4 = item
|
||||
$oldoptlist = 0;
|
||||
$nospace = 0;
|
||||
$synopsis = 0;
|
||||
$reference = 0;
|
||||
$block = 0;
|
||||
$ext = 0;
|
||||
$extopt = 0;
|
||||
$literal = 0;
|
||||
|
||||
while ($line = <STDIN>)
|
||||
{
|
||||
if ($line !~ /^\./)
|
||||
{
|
||||
print $line;
|
||||
print ".br\n"
|
||||
if ($literal);
|
||||
next;
|
||||
}
|
||||
|
||||
$line =~ s/^\.//;
|
||||
|
||||
next
|
||||
if ($line =~ m/\\"/);
|
||||
|
||||
$line = ParseMacro($line);
|
||||
print($line)
|
||||
if (defined $line);
|
||||
}
|
||||
|
||||
|
||||
|
||||
sub ParseMacro # ($line)
|
||||
{
|
||||
my ($line) = @_;
|
||||
my (@words, $retval, $option, $parens);
|
||||
|
||||
@words = split(/\s+/, $line);
|
||||
$retval = '';
|
||||
$option = 0;
|
||||
$parens = 0;
|
||||
|
||||
# print('@words = ', scalar(@words), ': ', join(' ', @words), "\n");
|
||||
|
||||
while ($_ = shift @words)
|
||||
{
|
||||
# print "WORD: $_\n";
|
||||
|
||||
next
|
||||
if (/^(Li|Pf)$/);
|
||||
|
||||
if (/^Xo$/)
|
||||
{
|
||||
$ext = 1;
|
||||
$retval .= ' '
|
||||
if ($retval ne '' && $retval !~ m/[\n ]$/);
|
||||
next;
|
||||
}
|
||||
|
||||
if (/^Xc$/)
|
||||
{
|
||||
$ext = 0;
|
||||
$retval .= "\n"
|
||||
if (! $extopt);
|
||||
last;
|
||||
}
|
||||
|
||||
if (/^Bd$/)
|
||||
{
|
||||
$literal = 1
|
||||
if ($words[0] eq '-literal');
|
||||
$retval .= "\n";
|
||||
last;
|
||||
}
|
||||
|
||||
if (/^Ed$/)
|
||||
{
|
||||
$literal = 0;
|
||||
last;
|
||||
}
|
||||
|
||||
if (/^Ns$/)
|
||||
{
|
||||
$nospace = 1
|
||||
if (! $nospace);
|
||||
$retval =~ s/ $//;
|
||||
next;
|
||||
}
|
||||
|
||||
if (/^No$/)
|
||||
{
|
||||
$retval =~ s/ $//;
|
||||
$retval .= shift @words;
|
||||
next;
|
||||
}
|
||||
|
||||
if (/^Dq$/)
|
||||
{
|
||||
$retval .= '``';
|
||||
do
|
||||
{
|
||||
$retval .= (shift @words) . ' ';
|
||||
}
|
||||
while (@words > 0 && $words[0] !~ m/^[\.,]/);
|
||||
$retval =~ s/ $//;
|
||||
$retval .= '\'\'';
|
||||
$nospace = 1
|
||||
if (! $nospace && $words[0] =~ m/^[\.,]/);
|
||||
next;
|
||||
}
|
||||
|
||||
if (/^(Sq|Ql)$/)
|
||||
{
|
||||
$retval .= '`' . (shift @words) . '\'';
|
||||
$nospace = 1
|
||||
if (! $nospace && $words[0] =~ m/^[\.,]/);
|
||||
next;
|
||||
}
|
||||
|
||||
# if (/^Ic$/)
|
||||
# {
|
||||
# $retval .= '\\fB' . shift(@words) . '\\fP';
|
||||
# next;
|
||||
# }
|
||||
|
||||
if (/^Oo$/)
|
||||
{
|
||||
# $retval .= "[\\c\n";
|
||||
$extopt = 1;
|
||||
$nospace = 1
|
||||
if (! $nospace);
|
||||
$retval .= '[';
|
||||
next;
|
||||
}
|
||||
|
||||
if (/^Oc$/)
|
||||
{
|
||||
$extopt = 0;
|
||||
$retval .= ']';
|
||||
next;
|
||||
}
|
||||
|
||||
$retval .= ' '
|
||||
if (! $nospace && $retval ne '' && $retval !~ m/[\n ]$/);
|
||||
$nospace = 0
|
||||
if ($nospace == 1);
|
||||
|
||||
if (/^Dd$/)
|
||||
{
|
||||
$date = join(' ', @words);
|
||||
return undef;
|
||||
}
|
||||
|
||||
if (/^Dt$/)
|
||||
{
|
||||
$id = join(' ', @words);
|
||||
return undef;
|
||||
}
|
||||
|
||||
if (/^Os$/)
|
||||
{
|
||||
$retval .= '.TH '
|
||||
. $id
|
||||
. " \"$date\" \""
|
||||
. join(' ', @words)
|
||||
. "\"";
|
||||
last;
|
||||
}
|
||||
|
||||
if (/^Sh$/)
|
||||
{
|
||||
$retval .= '.SH';
|
||||
if ($words[0] eq 'SYNOPSIS')
|
||||
{
|
||||
$synopsis = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$synopsis = 0;
|
||||
}
|
||||
next;
|
||||
}
|
||||
|
||||
if (/^Xr$/)
|
||||
{
|
||||
$retval .= '\\fB' . (shift @words) .
|
||||
'\\fP(' . (shift @words) . ')'
|
||||
. (shift @words);
|
||||
last;
|
||||
}
|
||||
|
||||
if (/^Rs/)
|
||||
{
|
||||
@refauthors = ();
|
||||
$reftitle = '';
|
||||
$refissue = '';
|
||||
$refdate = '';
|
||||
$refopt = '';
|
||||
$reference = 1;
|
||||
last;
|
||||
}
|
||||
|
||||
if (/^Re/)
|
||||
{
|
||||
$retval .= "\n";
|
||||
|
||||
# authors
|
||||
while (scalar(@refauthors) > 1)
|
||||
{
|
||||
$retval .= shift(@refauthors) . ', ';
|
||||
}
|
||||
$retval .= 'and '
|
||||
if ($retval ne '');
|
||||
$retval .= shift(@refauthors);
|
||||
|
||||
# title
|
||||
$retval .= ', \\fI' . $reftitle . '\\fP';
|
||||
|
||||
# issue
|
||||
$retval .= ', ' . $refissue
|
||||
if ($refissue ne '');
|
||||
|
||||
# date
|
||||
$retval .= ', ' . $refdate
|
||||
if ($refdate ne '');
|
||||
|
||||
# optional info
|
||||
$retval .= ', ' . $refopt
|
||||
if ($refopt ne '');
|
||||
|
||||
$retval .= ".\n";
|
||||
|
||||
$reference = 0;
|
||||
last;
|
||||
}
|
||||
|
||||
if ($reference)
|
||||
{
|
||||
if (/^%A$/)
|
||||
{
|
||||
unshift(@refauthors, join(' ', @words));
|
||||
last;
|
||||
}
|
||||
|
||||
if (/^%T$/)
|
||||
{
|
||||
$reftitle = join(' ', @words);
|
||||
$reftitle =~ s/^"//;
|
||||
$reftitle =~ s/"$//;
|
||||
last;
|
||||
}
|
||||
|
||||
if (/^%N$/)
|
||||
{
|
||||
$refissue = join(' ', @words);
|
||||
last;
|
||||
}
|
||||
|
||||
if (/^%D$/)
|
||||
{
|
||||
$refdate = join(' ', @words);
|
||||
last;
|
||||
}
|
||||
|
||||
if (/^%O$/)
|
||||
{
|
||||
$refopt = join(' ', @words);
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
if (/^Nm$/)
|
||||
{
|
||||
my $n = $name;
|
||||
$n = shift @words
|
||||
if (@words > 0);
|
||||
$name = $n unless $name;
|
||||
$retval .= ".br\n"
|
||||
if ($synopsis);
|
||||
$retval .= "\\fB$n\\fP";
|
||||
$nospace = 1
|
||||
if (! $nospace && $words[0] =~ m/^[\.,]/);
|
||||
next;
|
||||
}
|
||||
|
||||
if (/^Nd$/)
|
||||
{
|
||||
$retval .= '\\-';
|
||||
next;
|
||||
}
|
||||
|
||||
if (/^Fl$/)
|
||||
{
|
||||
$retval .= '\\fB\\-' . (shift @words) . '\\fP';
|
||||
$nospace = 1
|
||||
if (! $nospace && $words[0] =~ m/^[\.,]/);
|
||||
next;
|
||||
}
|
||||
|
||||
if (/^Ar$/)
|
||||
{
|
||||
$retval .= '\\fI';
|
||||
if (! defined $words[0])
|
||||
{
|
||||
$retval .= 'file ...\\fP';
|
||||
}
|
||||
else
|
||||
{
|
||||
$retval .= shift(@words) . '\\fP';
|
||||
while ($words[0] eq '|')
|
||||
{
|
||||
$retval .= ' ' . shift(@words);
|
||||
$retval .= ' \\fI' . shift(@words);
|
||||
$retval .= '\\fP';
|
||||
}
|
||||
}
|
||||
$nospace = 1
|
||||
if (! $nospace && $words[0] =~ m/^[\.,]/);
|
||||
next;
|
||||
}
|
||||
|
||||
if (/^Cm$/)
|
||||
{
|
||||
$retval .= '\\fB' . (shift @words) . '\\fP';
|
||||
while ($words[0] =~ m/^[\.,:)]$/)
|
||||
{
|
||||
$retval .= shift(@words);
|
||||
}
|
||||
next;
|
||||
}
|
||||
|
||||
if (/^Op$/)
|
||||
{
|
||||
$option = 1;
|
||||
$nospace = 1
|
||||
if (! $nospace);
|
||||
$retval .= '[';
|
||||
# my $tmp = pop(@words);
|
||||
# $tmp .= ']';
|
||||
# push(@words, $tmp);
|
||||
next;
|
||||
}
|
||||
|
||||
if (/^Pp$/)
|
||||
{
|
||||
$retval .= "\n";
|
||||
next;
|
||||
}
|
||||
|
||||
if (/^Ss$/)
|
||||
{
|
||||
$retval .= '.SS';
|
||||
next;
|
||||
}
|
||||
|
||||
if (/^Pa$/ && ! $option)
|
||||
{
|
||||
$retval .= '\\fI';
|
||||
$retval .= '\\&'
|
||||
if ($words[0] =~ m/^\./);
|
||||
$retval .= (shift @words) . '\\fP';
|
||||
while ($words[0] =~ m/^[\.,:;)]$/)
|
||||
{
|
||||
$retval .= shift(@words);
|
||||
}
|
||||
# $nospace = 1
|
||||
# if (! $nospace && $words[0] =~ m/^[\.,:)]/);
|
||||
next;
|
||||
}
|
||||
|
||||
if (/^Dv$/)
|
||||
{
|
||||
$retval .= '.BR';
|
||||
next;
|
||||
}
|
||||
|
||||
if (/^(Em|Ev)$/)
|
||||
{
|
||||
$retval .= '.IR';
|
||||
next;
|
||||
}
|
||||
|
||||
if (/^Pq$/)
|
||||
{
|
||||
$retval .= '(';
|
||||
$nospace = 1;
|
||||
$parens = 1;
|
||||
next;
|
||||
}
|
||||
|
||||
if (/^(S[xy])$/)
|
||||
{
|
||||
$retval .= '.B ' . join(' ', @words);
|
||||
last;
|
||||
}
|
||||
|
||||
if (/^Ic$/)
|
||||
{
|
||||
$retval .= '\\fB';
|
||||
while (defined $words[0]
|
||||
&& $words[0] !~ m/^[\.,]/)
|
||||
{
|
||||
if ($words[0] eq 'Op')
|
||||
{
|
||||
shift(@words);
|
||||
$retval .= '[';
|
||||
my $tmp = pop(@words);
|
||||
$tmp .= ']';
|
||||
push(@words, $tmp);
|
||||
next;
|
||||
}
|
||||
if ($words[0] eq 'Ar')
|
||||
{
|
||||
shift @words;
|
||||
$retval .= '\\fI';
|
||||
$retval .= shift @words;
|
||||
$retval .= '\\fP';
|
||||
}
|
||||
else
|
||||
{
|
||||
$retval .= shift @words;
|
||||
}
|
||||
$retval .= ' '
|
||||
if (! $nospace);
|
||||
}
|
||||
$retval =~ s/ $//;
|
||||
$retval .= '\\fP';
|
||||
$retval .= shift @words
|
||||
if (defined $words[0]);
|
||||
last;
|
||||
}
|
||||
|
||||
if (/^Bl$/)
|
||||
{
|
||||
$oldoptlist = $optlist;
|
||||
if ($words[0] eq '-bullet')
|
||||
{
|
||||
$optlist = 1;
|
||||
}
|
||||
elsif ($words[0] eq '-enum')
|
||||
{
|
||||
$optlist = 2;
|
||||
$enum = 0;
|
||||
}
|
||||
elsif ($words[0] eq '-tag')
|
||||
{
|
||||
$optlist = 3;
|
||||
}
|
||||
elsif ($words[0] eq '-item')
|
||||
{
|
||||
$optlist = 4;
|
||||
}
|
||||
last;
|
||||
}
|
||||
|
||||
if (/^El$/)
|
||||
{
|
||||
$optlist = $oldoptlist;
|
||||
next;
|
||||
}
|
||||
|
||||
if ($optlist && /^It$/)
|
||||
{
|
||||
if ($optlist == 1)
|
||||
{
|
||||
# bullets
|
||||
$retval .= '.IP \\(bu';
|
||||
next;
|
||||
}
|
||||
|
||||
if ($optlist == 2)
|
||||
{
|
||||
# enum
|
||||
$retval .= '.IP ' . (++$enum) . '.';
|
||||
next;
|
||||
}
|
||||
|
||||
if ($optlist == 3)
|
||||
{
|
||||
# tags
|
||||
$retval .= ".TP\n";
|
||||
if ($words[0] =~ m/^(Pa|Ev)$/)
|
||||
{
|
||||
shift @words;
|
||||
$retval .= '.B';
|
||||
}
|
||||
next;
|
||||
}
|
||||
|
||||
if ($optlist == 4)
|
||||
{
|
||||
# item
|
||||
$retval .= ".IP\n";
|
||||
next;
|
||||
}
|
||||
|
||||
next;
|
||||
}
|
||||
|
||||
if (/^Sm$/)
|
||||
{
|
||||
if ($words[0] eq 'off')
|
||||
{
|
||||
$nospace = 2;
|
||||
}
|
||||
elsif ($words[0] eq 'on')
|
||||
{
|
||||
# $retval .= "\n";
|
||||
$nospace = 0;
|
||||
}
|
||||
shift @words;
|
||||
next;
|
||||
}
|
||||
|
||||
$retval .= "$_";
|
||||
}
|
||||
|
||||
return undef
|
||||
if ($retval eq '.');
|
||||
|
||||
$retval =~ s/^\.([^a-zA-Z])/$1/;
|
||||
# $retval =~ s/ $//;
|
||||
|
||||
$retval .= ')'
|
||||
if ($parens == 1);
|
||||
|
||||
$retval .= ']'
|
||||
if ($option == 1);
|
||||
|
||||
# $retval .= ' '
|
||||
# if ($nospace && $retval ne '' && $retval !~ m/\n$/);
|
||||
|
||||
# $retval .= ' '
|
||||
# if ($extended && $retval !~ m/ $/);
|
||||
|
||||
$retval .= ' '
|
||||
if ($ext && ! $extopt && $retval !~ m/ $/);
|
||||
|
||||
$retval .= "\n"
|
||||
if (! $ext && ! $extopt && $retval ne '' && $retval !~ m/\n$/);
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
|
@ -1,12 +0,0 @@
|
||||
/* $Id: basename.h,v 1.3 2003/02/25 03:32:16 djm Exp $ */
|
||||
|
||||
#ifndef _BASENAME_H
|
||||
#define _BASENAME_H
|
||||
#include "config.h"
|
||||
|
||||
#if !defined(HAVE_BASENAME)
|
||||
|
||||
char *basename(const char *path);
|
||||
|
||||
#endif /* !defined(HAVE_BASENAME) */
|
||||
#endif /* _BASENAME_H */
|
@ -1,12 +0,0 @@
|
||||
/* $Id: bindresvport.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */
|
||||
|
||||
#ifndef _BSD_BINDRESVPORT_H
|
||||
#define _BSD_BINDRESVPORT_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifndef HAVE_BINDRESVPORT_SA
|
||||
int bindresvport_sa(int sd, struct sockaddr *sa);
|
||||
#endif /* !HAVE_BINDRESVPORT_SA */
|
||||
|
||||
#endif /* _BSD_BINDRESVPORT_H */
|
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1999-2000 Damien Miller. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* $Id: bsd-arc4random.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */
|
||||
|
||||
#ifndef _BSD_ARC4RANDOM_H
|
||||
#define _BSD_ARC4RANDOM_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifndef HAVE_ARC4RANDOM
|
||||
unsigned int arc4random(void);
|
||||
void arc4random_stir(void);
|
||||
#endif /* !HAVE_ARC4RANDOM */
|
||||
|
||||
#endif /* _BSD_ARC4RANDOM_H */
|
@ -1,14 +0,0 @@
|
||||
/* $Id: bsd-getpeereid.h,v 1.1 2002/09/12 00:33:02 djm Exp $ */
|
||||
|
||||
#ifndef _BSD_GETPEEREID_H
|
||||
#define _BSD_GETPEEREID_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <sys/types.h> /* For uid_t, gid_t */
|
||||
|
||||
#ifndef HAVE_GETPEEREID
|
||||
int getpeereid(int , uid_t *, gid_t *);
|
||||
#endif /* HAVE_GETPEEREID */
|
||||
|
||||
#endif /* _BSD_GETPEEREID_H */
|
@ -1,19 +0,0 @@
|
||||
/* $Id: bsd-snprintf.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */
|
||||
|
||||
#ifndef _BSD_SNPRINTF_H
|
||||
#define _BSD_SNPRINTF_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <sys/types.h> /* For size_t */
|
||||
|
||||
#ifndef HAVE_SNPRINTF
|
||||
int snprintf(char *str, size_t count, const char *fmt, ...);
|
||||
#endif /* !HAVE_SNPRINTF */
|
||||
|
||||
#ifndef HAVE_VSNPRINTF
|
||||
int vsnprintf(char *str, size_t count, const char *fmt, va_list args);
|
||||
#endif /* !HAVE_SNPRINTF */
|
||||
|
||||
|
||||
#endif /* _BSD_SNPRINTF_H */
|
@ -1,11 +0,0 @@
|
||||
/* $Id: daemon.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */
|
||||
|
||||
#ifndef _BSD_DAEMON_H
|
||||
#define _BSD_DAEMON_H
|
||||
|
||||
#include "config.h"
|
||||
#ifndef HAVE_DAEMON
|
||||
int daemon(int nochdir, int noclose);
|
||||
#endif /* !HAVE_DAEMON */
|
||||
|
||||
#endif /* _BSD_DAEMON_H */
|
@ -1,5 +0,0 @@
|
||||
#ifndef HAVE_DIRNAME
|
||||
|
||||
char *dirname(const char *path);
|
||||
|
||||
#endif
|
@ -1,14 +0,0 @@
|
||||
/*
|
||||
* fake library for ssh
|
||||
*
|
||||
* This file is included in getaddrinfo.c and getnameinfo.c.
|
||||
* See getaddrinfo.c and getnameinfo.c.
|
||||
*/
|
||||
|
||||
/* $Id: fake-gai-errnos.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */
|
||||
|
||||
/* for old netdb.h */
|
||||
#ifndef EAI_NODATA
|
||||
#define EAI_NODATA 1
|
||||
#define EAI_MEMORY 2
|
||||
#endif
|
@ -1,135 +0,0 @@
|
||||
/*
|
||||
* fake library for ssh
|
||||
*
|
||||
* This file includes getaddrinfo(), freeaddrinfo() and gai_strerror().
|
||||
* These funtions are defined in rfc2133.
|
||||
*
|
||||
* But these functions are not implemented correctly. The minimum subset
|
||||
* is implemented for ssh use only. For exapmle, this routine assumes
|
||||
* that ai_family is AF_INET. Don't use it for another purpose.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
#include "ssh.h"
|
||||
|
||||
RCSID("$Id: fake-getaddrinfo.c,v 1.5 2003/03/24 02:35:59 djm Exp $");
|
||||
|
||||
#ifndef HAVE_GAI_STRERROR
|
||||
char *gai_strerror(int ecode)
|
||||
{
|
||||
switch (ecode) {
|
||||
case EAI_NODATA:
|
||||
return "no address associated with hostname.";
|
||||
case EAI_MEMORY:
|
||||
return "memory allocation failure.";
|
||||
default:
|
||||
return "unknown error.";
|
||||
}
|
||||
}
|
||||
#endif /* !HAVE_GAI_STRERROR */
|
||||
|
||||
#ifndef HAVE_FREEADDRINFO
|
||||
void freeaddrinfo(struct addrinfo *ai)
|
||||
{
|
||||
struct addrinfo *next;
|
||||
|
||||
do {
|
||||
next = ai->ai_next;
|
||||
free(ai);
|
||||
} while (NULL != (ai = next));
|
||||
}
|
||||
#endif /* !HAVE_FREEADDRINFO */
|
||||
|
||||
#ifndef HAVE_GETADDRINFO
|
||||
static struct addrinfo *malloc_ai(int port, u_long addr)
|
||||
{
|
||||
struct addrinfo *ai;
|
||||
|
||||
ai = malloc(sizeof(struct addrinfo) + sizeof(struct sockaddr_in));
|
||||
if (ai == NULL)
|
||||
return(NULL);
|
||||
|
||||
memset(ai, 0, sizeof(struct addrinfo) + sizeof(struct sockaddr_in));
|
||||
|
||||
ai->ai_addr = (struct sockaddr *)(ai + 1);
|
||||
/* XXX -- ssh doesn't use sa_len */
|
||||
ai->ai_addrlen = sizeof(struct sockaddr_in);
|
||||
ai->ai_addr->sa_family = ai->ai_family = AF_INET;
|
||||
|
||||
((struct sockaddr_in *)(ai)->ai_addr)->sin_port = port;
|
||||
((struct sockaddr_in *)(ai)->ai_addr)->sin_addr.s_addr = addr;
|
||||
|
||||
return(ai);
|
||||
}
|
||||
|
||||
int getaddrinfo(const char *hostname, const char *servname,
|
||||
const struct addrinfo *hints, struct addrinfo **res)
|
||||
{
|
||||
struct addrinfo *cur, *prev = NULL;
|
||||
struct hostent *hp;
|
||||
struct servent *sp;
|
||||
struct in_addr in;
|
||||
int i;
|
||||
long int port;
|
||||
u_long addr;
|
||||
|
||||
port = 0;
|
||||
if (servname != NULL) {
|
||||
char *cp;
|
||||
|
||||
port = strtol(servname, &cp, 10);
|
||||
if (port > 0 && port <= 65535 && *cp == '\0')
|
||||
port = htons(port);
|
||||
else if ((sp = getservbyname(servname, NULL)) != NULL)
|
||||
port = sp->s_port;
|
||||
else
|
||||
port = 0;
|
||||
}
|
||||
|
||||
if (hints && hints->ai_flags & AI_PASSIVE) {
|
||||
addr = htonl(0x00000000);
|
||||
if (hostname && inet_aton(hostname, &in) != 0)
|
||||
addr = in.s_addr;
|
||||
if (NULL != (*res = malloc_ai(port, addr)))
|
||||
return 0;
|
||||
else
|
||||
return EAI_MEMORY;
|
||||
}
|
||||
|
||||
if (!hostname) {
|
||||
if (NULL != (*res = malloc_ai(port, htonl(0x7f000001))))
|
||||
return 0;
|
||||
else
|
||||
return EAI_MEMORY;
|
||||
}
|
||||
|
||||
if (inet_aton(hostname, &in)) {
|
||||
if (NULL != (*res = malloc_ai(port, in.s_addr)))
|
||||
return 0;
|
||||
else
|
||||
return EAI_MEMORY;
|
||||
}
|
||||
|
||||
hp = gethostbyname(hostname);
|
||||
if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) {
|
||||
for (i = 0; hp->h_addr_list[i]; i++) {
|
||||
cur = malloc_ai(port, ((struct in_addr *)hp->h_addr_list[i])->s_addr);
|
||||
if (cur == NULL) {
|
||||
if (*res)
|
||||
freeaddrinfo(*res);
|
||||
return EAI_MEMORY;
|
||||
}
|
||||
|
||||
if (prev)
|
||||
prev->ai_next = cur;
|
||||
else
|
||||
*res = cur;
|
||||
|
||||
prev = cur;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
return EAI_NODATA;
|
||||
}
|
||||
#endif /* !HAVE_GETADDRINFO */
|
@ -1,47 +0,0 @@
|
||||
/* $Id: fake-getaddrinfo.h,v 1.4 2003/02/24 01:35:09 djm Exp $ */
|
||||
|
||||
#ifndef _FAKE_GETADDRINFO_H
|
||||
#define _FAKE_GETADDRINFO_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "fake-gai-errnos.h"
|
||||
|
||||
#ifndef AI_PASSIVE
|
||||
# define AI_PASSIVE 1
|
||||
# define AI_CANONNAME 2
|
||||
#endif
|
||||
|
||||
#ifndef NI_NUMERICHOST
|
||||
# define NI_NUMERICHOST 2
|
||||
# define NI_NAMEREQD 4
|
||||
# define NI_NUMERICSERV 8
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRUCT_ADDRINFO
|
||||
struct addrinfo {
|
||||
int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
|
||||
int ai_family; /* PF_xxx */
|
||||
int ai_socktype; /* SOCK_xxx */
|
||||
int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
|
||||
size_t ai_addrlen; /* length of ai_addr */
|
||||
char *ai_canonname; /* canonical name for hostname */
|
||||
struct sockaddr *ai_addr; /* binary address */
|
||||
struct addrinfo *ai_next; /* next structure in linked list */
|
||||
};
|
||||
#endif /* !HAVE_STRUCT_ADDRINFO */
|
||||
|
||||
#ifndef HAVE_GETADDRINFO
|
||||
int getaddrinfo(const char *hostname, const char *servname,
|
||||
const struct addrinfo *hints, struct addrinfo **res);
|
||||
#endif /* !HAVE_GETADDRINFO */
|
||||
|
||||
#ifndef HAVE_GAI_STRERROR
|
||||
char *gai_strerror(int ecode);
|
||||
#endif /* !HAVE_GAI_STRERROR */
|
||||
|
||||
#ifndef HAVE_FREEADDRINFO
|
||||
void freeaddrinfo(struct addrinfo *ai);
|
||||
#endif /* !HAVE_FREEADDRINFO */
|
||||
|
||||
#endif /* _FAKE_GETADDRINFO_H */
|
@ -1,55 +0,0 @@
|
||||
/*
|
||||
* fake library for ssh
|
||||
*
|
||||
* This file includes getnameinfo().
|
||||
* These funtions are defined in rfc2133.
|
||||
*
|
||||
* But these functions are not implemented correctly. The minimum subset
|
||||
* is implemented for ssh use only. For exapmle, this routine assumes
|
||||
* that ai_family is AF_INET. Don't use it for another purpose.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
#include "ssh.h"
|
||||
|
||||
RCSID("$Id: fake-getnameinfo.c,v 1.2 2001/02/09 01:55:36 djm Exp $");
|
||||
|
||||
#ifndef HAVE_GETNAMEINFO
|
||||
int getnameinfo(const struct sockaddr *sa, size_t salen, char *host,
|
||||
size_t hostlen, char *serv, size_t servlen, int flags)
|
||||
{
|
||||
struct sockaddr_in *sin = (struct sockaddr_in *)sa;
|
||||
struct hostent *hp;
|
||||
char tmpserv[16];
|
||||
|
||||
if (serv) {
|
||||
snprintf(tmpserv, sizeof(tmpserv), "%d", ntohs(sin->sin_port));
|
||||
if (strlen(tmpserv) >= servlen)
|
||||
return EAI_MEMORY;
|
||||
else
|
||||
strcpy(serv, tmpserv);
|
||||
}
|
||||
|
||||
if (host) {
|
||||
if (flags & NI_NUMERICHOST) {
|
||||
if (strlen(inet_ntoa(sin->sin_addr)) >= hostlen)
|
||||
return EAI_MEMORY;
|
||||
|
||||
strcpy(host, inet_ntoa(sin->sin_addr));
|
||||
return 0;
|
||||
} else {
|
||||
hp = gethostbyaddr((char *)&sin->sin_addr,
|
||||
sizeof(struct in_addr), AF_INET);
|
||||
if (hp == NULL)
|
||||
return EAI_NODATA;
|
||||
|
||||
if (strlen(hp->h_name) >= hostlen)
|
||||
return EAI_MEMORY;
|
||||
|
||||
strcpy(host, hp->h_name);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif /* !HAVE_GETNAMEINFO */
|
@ -1,20 +0,0 @@
|
||||
/* $Id: fake-getnameinfo.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */
|
||||
|
||||
#ifndef _FAKE_GETNAMEINFO_H
|
||||
#define _FAKE_GETNAMEINFO_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifndef HAVE_GETNAMEINFO
|
||||
int getnameinfo(const struct sockaddr *sa, size_t salen, char *host,
|
||||
size_t hostlen, char *serv, size_t servlen, int flags);
|
||||
#endif /* !HAVE_GETNAMEINFO */
|
||||
|
||||
#ifndef NI_MAXSERV
|
||||
# define NI_MAXSERV 32
|
||||
#endif /* !NI_MAXSERV */
|
||||
#ifndef NI_MAXHOST
|
||||
# define NI_MAXHOST 1025
|
||||
#endif /* !NI_MAXHOST */
|
||||
|
||||
#endif /* _FAKE_GETNAMEINFO_H */
|
@ -1,47 +0,0 @@
|
||||
/* $Id: fake-socket.h,v 1.3 2002/04/12 03:35:40 tim Exp $ */
|
||||
|
||||
#ifndef _FAKE_SOCKET_H
|
||||
#define _FAKE_SOCKET_H
|
||||
|
||||
#include "includes.h"
|
||||
#include "sys/types.h"
|
||||
|
||||
#ifndef HAVE_STRUCT_SOCKADDR_STORAGE
|
||||
# define _SS_MAXSIZE 128 /* Implementation specific max size */
|
||||
# define _SS_PADSIZE (_SS_MAXSIZE - sizeof (struct sockaddr))
|
||||
|
||||
struct sockaddr_storage {
|
||||
struct sockaddr ss_sa;
|
||||
char __ss_pad2[_SS_PADSIZE];
|
||||
};
|
||||
# define ss_family ss_sa.sa_family
|
||||
#endif /* !HAVE_STRUCT_SOCKADDR_STORAGE */
|
||||
|
||||
#ifndef IN6_IS_ADDR_LOOPBACK
|
||||
# define IN6_IS_ADDR_LOOPBACK(a) \
|
||||
(((u_int32_t *) (a))[0] == 0 && ((u_int32_t *) (a))[1] == 0 && \
|
||||
((u_int32_t *) (a))[2] == 0 && ((u_int32_t *) (a))[3] == htonl (1))
|
||||
#endif /* !IN6_IS_ADDR_LOOPBACK */
|
||||
|
||||
#ifndef HAVE_STRUCT_IN6_ADDR
|
||||
struct in6_addr {
|
||||
u_int8_t s6_addr[16];
|
||||
};
|
||||
#endif /* !HAVE_STRUCT_IN6_ADDR */
|
||||
|
||||
#ifndef HAVE_STRUCT_SOCKADDR_IN6
|
||||
struct sockaddr_in6 {
|
||||
unsigned short sin6_family;
|
||||
u_int16_t sin6_port;
|
||||
u_int32_t sin6_flowinfo;
|
||||
struct in6_addr sin6_addr;
|
||||
};
|
||||
#endif /* !HAVE_STRUCT_SOCKADDR_IN6 */
|
||||
|
||||
#ifndef AF_INET6
|
||||
/* Define it to something that should never appear */
|
||||
#define AF_INET6 AF_MAX
|
||||
#endif
|
||||
|
||||
#endif /* !_FAKE_SOCKET_H */
|
||||
|
@ -1,12 +0,0 @@
|
||||
/* $Id: getcwd.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */
|
||||
|
||||
#ifndef _BSD_GETCWD_H
|
||||
#define _BSD_GETCWD_H
|
||||
#include "config.h"
|
||||
|
||||
#if !defined(HAVE_GETCWD)
|
||||
|
||||
char *getcwd(char *pt, size_t size);
|
||||
|
||||
#endif /* !defined(HAVE_GETCWD) */
|
||||
#endif /* _BSD_GETCWD_H */
|
@ -1,16 +0,0 @@
|
||||
/* $Id: getgrouplist.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */
|
||||
|
||||
#ifndef _BSD_GETGROUPLIST_H
|
||||
#define _BSD_GETGROUPLIST_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifndef HAVE_GETGROUPLIST
|
||||
|
||||
#include <grp.h>
|
||||
|
||||
int getgrouplist(const char *, gid_t, gid_t *, int *);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,14 +0,0 @@
|
||||
/* $Id: getopt.h,v 1.4 2001/09/18 05:05:21 djm Exp $ */
|
||||
|
||||
#ifndef _BSDGETOPT_H
|
||||
#define _BSDGETOPT_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if !defined(HAVE_GETOPT) || !defined(HAVE_GETOPT_OPTRESET)
|
||||
|
||||
int BSDgetopt(int argc, char * const *argv, const char *opts);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _BSDGETOPT_H */
|
@ -1,12 +0,0 @@
|
||||
/* $Id: inet_aton.h,v 1.4 2001/07/16 02:07:51 tim Exp $ */
|
||||
|
||||
#ifndef _BSD_INET_ATON_H
|
||||
#define _BSD_INET_ATON_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifndef HAVE_INET_ATON
|
||||
int inet_aton(const char *cp, struct in_addr *addr);
|
||||
#endif /* HAVE_INET_ATON */
|
||||
|
||||
#endif /* _BSD_INET_ATON_H */
|
@ -1,12 +0,0 @@
|
||||
/* $Id: inet_ntoa.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */
|
||||
|
||||
#ifndef _BSD_INET_NTOA_H
|
||||
#define _BSD_INET_NTOA_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if defined(BROKEN_INET_NTOA) || !defined(HAVE_INET_NTOA)
|
||||
char *inet_ntoa(struct in_addr in);
|
||||
#endif /* defined(BROKEN_INET_NTOA) || !defined(HAVE_INET_NTOA) */
|
||||
|
||||
#endif /* _BSD_INET_NTOA_H */
|
@ -1,13 +0,0 @@
|
||||
/* $Id: inet_ntop.h,v 1.4 2001/08/09 00:56:53 mouring Exp $ */
|
||||
|
||||
#ifndef _BSD_INET_NTOP_H
|
||||
#define _BSD_INET_NTOP_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifndef HAVE_INET_NTOP
|
||||
const char *
|
||||
inet_ntop(int af, const void *src, char *dst, size_t size);
|
||||
#endif /* !HAVE_INET_NTOP */
|
||||
|
||||
#endif /* _BSD_INET_NTOP_H */
|
@ -1,13 +0,0 @@
|
||||
/* $Id: mktemp.h,v 1.3 2003/01/07 04:18:33 djm Exp $ */
|
||||
|
||||
#ifndef _BSD_MKTEMP_H
|
||||
#define _BSD_MKTEMP_H
|
||||
|
||||
#include "config.h"
|
||||
#if !defined(HAVE_MKDTEMP) || defined(HAVE_STRICT_MKSTEMP)
|
||||
int mkstemps(char *path, int slen);
|
||||
int mkstemp(char *path);
|
||||
char *mkdtemp(char *path);
|
||||
#endif /* !defined(HAVE_MKDTEMP) || defined(HAVE_STRICT_MKSTEMP) */
|
||||
|
||||
#endif /* _BSD_MKTEMP_H */
|
@ -1,13 +0,0 @@
|
||||
/* $Id: realpath.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */
|
||||
|
||||
#ifndef _BSD_REALPATH_H
|
||||
#define _BSD_REALPATH_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if !defined(HAVE_REALPATH) || defined(BROKEN_REALPATH)
|
||||
|
||||
char *realpath(const char *path, char *resolved);
|
||||
|
||||
#endif /* !defined(HAVE_REALPATH) || defined(BROKEN_REALPATH) */
|
||||
#endif /* _BSD_REALPATH_H */
|
@ -1,12 +0,0 @@
|
||||
/* $Id: rresvport.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */
|
||||
|
||||
#ifndef _BSD_RRESVPORT_H
|
||||
#define _BSD_RRESVPORT_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifndef HAVE_RRESVPORT_AF
|
||||
int rresvport_af(int *alport, sa_family_t af);
|
||||
#endif /* !HAVE_RRESVPORT_AF */
|
||||
|
||||
#endif /* _BSD_RRESVPORT_H */
|
@ -1,14 +0,0 @@
|
||||
/* $Id: setenv.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */
|
||||
|
||||
#ifndef _BSD_SETENV_H
|
||||
#define _BSD_SETENV_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifndef HAVE_SETENV
|
||||
|
||||
int setenv(register const char *name, register const char *value, int rewrite);
|
||||
|
||||
#endif /* !HAVE_SETENV */
|
||||
|
||||
#endif /* _BSD_SETENV_H */
|
@ -1,13 +0,0 @@
|
||||
/* $Id: setproctitle.h,v 1.3 2003/01/09 22:53:13 djm Exp $ */
|
||||
|
||||
#ifndef _BSD_SETPROCTITLE_H
|
||||
#define _BSD_SETPROCTITLE_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifndef HAVE_SETPROCTITLE
|
||||
void setproctitle(const char *fmt, ...);
|
||||
void compat_init_setproctitle(int argc, char *argv[]);
|
||||
#endif
|
||||
|
||||
#endif /* _BSD_SETPROCTITLE_H */
|
@ -1,12 +0,0 @@
|
||||
/* $Id: strlcat.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */
|
||||
|
||||
#ifndef _BSD_STRLCAT_H
|
||||
#define _BSD_STRLCAT_H
|
||||
|
||||
#include "config.h"
|
||||
#ifndef HAVE_STRLCAT
|
||||
#include <sys/types.h>
|
||||
size_t strlcat(char *dst, const char *src, size_t siz);
|
||||
#endif /* !HAVE_STRLCAT */
|
||||
|
||||
#endif /* _BSD_STRLCAT_H */
|
@ -1,12 +0,0 @@
|
||||
/* $Id: strlcpy.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */
|
||||
|
||||
#ifndef _BSD_STRLCPY_H
|
||||
#define _BSD_STRLCPY_H
|
||||
|
||||
#include "config.h"
|
||||
#ifndef HAVE_STRLCPY
|
||||
#include <sys/types.h>
|
||||
size_t strlcpy(char *dst, const char *src, size_t siz);
|
||||
#endif /* !HAVE_STRLCPY */
|
||||
|
||||
#endif /* _BSD_STRLCPY_H */
|
@ -1,7 +0,0 @@
|
||||
/* $Id: strmode.h,v 1.3 2001/06/09 02:22:17 mouring Exp $ */
|
||||
|
||||
#ifndef HAVE_STRMODE
|
||||
|
||||
void strmode(register mode_t mode, register char *p);
|
||||
|
||||
#endif
|
@ -1,12 +0,0 @@
|
||||
/* $Id: strsep.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */
|
||||
|
||||
#ifndef _BSD_STRSEP_H
|
||||
#define _BSD_STRSEP_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifndef HAVE_STRSEP
|
||||
char *strsep(char **stringp, const char *delim);
|
||||
#endif /* HAVE_STRSEP */
|
||||
|
||||
#endif /* _BSD_STRSEP_H */
|
@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
void *xmmap(size_t size);
|
@ -1,158 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1999 Dug Song. All rights reserved.
|
||||
* Copyright (c) 2002 Markus Friedl. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
#include "uuencode.h"
|
||||
|
||||
RCSID("$OpenBSD: radix.c,v 1.22 2002/09/09 14:54:15 markus Exp $");
|
||||
|
||||
#ifdef AFS
|
||||
#include <krb.h>
|
||||
|
||||
#include <radix.h>
|
||||
#include "bufaux.h"
|
||||
|
||||
int
|
||||
creds_to_radix(CREDENTIALS *creds, u_char *buf, size_t buflen)
|
||||
{
|
||||
Buffer b;
|
||||
int ret;
|
||||
|
||||
buffer_init(&b);
|
||||
|
||||
buffer_put_char(&b, 1); /* version */
|
||||
|
||||
buffer_append(&b, creds->service, strlen(creds->service));
|
||||
buffer_put_char(&b, '\0');
|
||||
buffer_append(&b, creds->instance, strlen(creds->instance));
|
||||
buffer_put_char(&b, '\0');
|
||||
buffer_append(&b, creds->realm, strlen(creds->realm));
|
||||
buffer_put_char(&b, '\0');
|
||||
buffer_append(&b, creds->pname, strlen(creds->pname));
|
||||
buffer_put_char(&b, '\0');
|
||||
buffer_append(&b, creds->pinst, strlen(creds->pinst));
|
||||
buffer_put_char(&b, '\0');
|
||||
|
||||
/* Null string to repeat the realm. */
|
||||
buffer_put_char(&b, '\0');
|
||||
|
||||
buffer_put_int(&b, creds->issue_date);
|
||||
buffer_put_int(&b, krb_life_to_time(creds->issue_date,
|
||||
creds->lifetime));
|
||||
buffer_append(&b, creds->session, sizeof(creds->session));
|
||||
buffer_put_short(&b, creds->kvno);
|
||||
|
||||
/* 32 bit size + data */
|
||||
buffer_put_string(&b, creds->ticket_st.dat, creds->ticket_st.length);
|
||||
|
||||
ret = uuencode(buffer_ptr(&b), buffer_len(&b), (char *)buf, buflen);
|
||||
|
||||
buffer_free(&b);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define GETSTRING(b, t, tlen) \
|
||||
do { \
|
||||
int i, found = 0; \
|
||||
for (i = 0; i < tlen; i++) { \
|
||||
if (buffer_len(b) == 0) \
|
||||
goto done; \
|
||||
t[i] = buffer_get_char(b); \
|
||||
if (t[i] == '\0') { \
|
||||
found = 1; \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
if (!found) \
|
||||
goto done; \
|
||||
} while(0)
|
||||
|
||||
int
|
||||
radix_to_creds(const char *buf, CREDENTIALS *creds)
|
||||
{
|
||||
Buffer b;
|
||||
u_char *space;
|
||||
char c, version, *p;
|
||||
u_int endTime, len;
|
||||
int blen, ret;
|
||||
|
||||
ret = 0;
|
||||
blen = strlen(buf);
|
||||
|
||||
/* sanity check for size */
|
||||
if (blen > 8192)
|
||||
return 0;
|
||||
|
||||
buffer_init(&b);
|
||||
space = buffer_append_space(&b, blen);
|
||||
|
||||
/* check version and length! */
|
||||
len = uudecode(buf, space, blen);
|
||||
if (len < 1)
|
||||
goto done;
|
||||
|
||||
version = buffer_get_char(&b);
|
||||
|
||||
GETSTRING(&b, creds->service, sizeof creds->service);
|
||||
GETSTRING(&b, creds->instance, sizeof creds->instance);
|
||||
GETSTRING(&b, creds->realm, sizeof creds->realm);
|
||||
GETSTRING(&b, creds->pname, sizeof creds->pname);
|
||||
GETSTRING(&b, creds->pinst, sizeof creds->pinst);
|
||||
|
||||
if (buffer_len(&b) == 0)
|
||||
goto done;
|
||||
|
||||
/* Ignore possibly different realm. */
|
||||
while (buffer_len(&b) > 0 && (c = buffer_get_char(&b)) != '\0')
|
||||
;
|
||||
|
||||
if (buffer_len(&b) == 0)
|
||||
goto done;
|
||||
|
||||
creds->issue_date = buffer_get_int(&b);
|
||||
|
||||
endTime = buffer_get_int(&b);
|
||||
creds->lifetime = krb_time_to_life(creds->issue_date, endTime);
|
||||
|
||||
len = buffer_len(&b);
|
||||
if (len < sizeof(creds->session))
|
||||
goto done;
|
||||
memcpy(&creds->session, buffer_ptr(&b), sizeof(creds->session));
|
||||
buffer_consume(&b, sizeof(creds->session));
|
||||
|
||||
creds->kvno = buffer_get_short(&b);
|
||||
|
||||
p = buffer_get_string(&b, &len);
|
||||
if (len < 0 || len > sizeof(creds->ticket_st.dat))
|
||||
goto done;
|
||||
memcpy(&creds->ticket_st.dat, p, len);
|
||||
creds->ticket_st.length = len;
|
||||
|
||||
ret = 1;
|
||||
done:
|
||||
buffer_free(&b);
|
||||
return ret;
|
||||
}
|
||||
#endif /* AFS */
|
@ -1,28 +0,0 @@
|
||||
/* $OpenBSD: radix.h,v 1.4 2001/06/26 17:27:24 markus Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999 Dug Song. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
int creds_to_radix(CREDENTIALS *, u_char *, size_t);
|
||||
int radix_to_creds(const char *, CREDENTIALS *);
|
@ -1,2 +0,0 @@
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAt6ttBacbgvLPsF1VWWfT51t55/5Mj62Xp8EaoH5SNSaLiGIgrrja077lKEept75U4uKFUYU5JJX9GPE9A7Y43LXv+/A6Jm4rEj/U0s4H8tf0UmzVC3t6xh0sRK0hYVNILyoHnIAgdY8CmOiybw7p6DxJY8MRAehD3n9+kFcachU= root@xenon
|
||||
1024 35 132789427207755621599908461558918671787816692978751485815532032934821830960131244604702969298486352138126114080367609979552547448841583955126231410604842765726397407176910594168641969541792069550006878863592030567875913190224374005367884774859544943329148178663694126456638431428703289837638970464685771819219 root@xenon
|
@ -1,32 +0,0 @@
|
||||
/* $OpenBSD: ssh-dss.h,v 1.6 2002/02/24 19:14:59 markus Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000 Markus Friedl. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef DSA_H
|
||||
#define DSA_H
|
||||
|
||||
int ssh_dss_sign(Key *, u_char **, u_int *, u_char *, u_int);
|
||||
int ssh_dss_verify(Key *, u_char *, u_int, u_char *, u_int);
|
||||
|
||||
#endif
|
@ -1,32 +0,0 @@
|
||||
/* $OpenBSD: ssh-rsa.h,v 1.6 2002/02/24 19:14:59 markus Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000 Markus Friedl. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef SSH_RSA_H
|
||||
#define SSH_RSA_H
|
||||
|
||||
int ssh_rsa_sign(Key *, u_char **, u_int *, u_char *, u_int);
|
||||
int ssh_rsa_verify(Key *, u_char *, u_int, u_char *, u_int);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user