From 97363a8b24601bad631f6f187c487a166f7eb959 Mon Sep 17 00:00:00 2001 From: Darren Tucker Date: Fri, 2 May 2003 23:42:25 +1000 Subject: - (dtucker) Move handling of bad password authentications into a platform specific record_failed_login() function (affects AIX & Unicos). --- openbsd-compat/bsd-cray.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'openbsd-compat/bsd-cray.h') diff --git a/openbsd-compat/bsd-cray.h b/openbsd-compat/bsd-cray.h index a09954f2f..d2489f4bf 100644 --- a/openbsd-compat/bsd-cray.h +++ b/openbsd-compat/bsd-cray.h @@ -1,5 +1,5 @@ /* - * $Id: bsd-cray.h,v 1.7 2003/03/21 01:05:38 mouring Exp $ + * $Id: bsd-cray.h,v 1.8 2003/05/02 13:42:25 dtucker Exp $ * * bsd-cray.h * @@ -42,6 +42,8 @@ void cray_init_job(struct passwd *); /* init cray job */ void cray_job_termination_handler(int); /* process end of job signal */ void cray_login_failure(char *username, int errcode); int cray_access_denied(char *username); +#define CUSTOM_FAILED_LOGIN 1 +void record_failed_login(const char *user, const char *ttyname); extern char cray_tmpdir[]; /* cray tmpdir */ #ifndef IA_SSHD #define IA_SSHD IA_LOGIN -- cgit v1.2.3 From 317412502b900ddecdafdfa171da99271846478b Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Mon, 19 May 2003 00:13:38 +1000 Subject: - (djm) Big KNF on openbsd-compat/ --- ChangeLog | 3 +- openbsd-compat/bsd-arc4random.c | 3 +- openbsd-compat/bsd-cray.c | 799 ++++++++++++++++++-------------------- openbsd-compat/bsd-cray.h | 27 +- openbsd-compat/bsd-cygwin_util.c | 93 ++--- openbsd-compat/bsd-cygwin_util.h | 8 +- openbsd-compat/bsd-getpeereid.h | 26 +- openbsd-compat/bsd-misc.c | 33 +- openbsd-compat/bsd-misc.h | 27 +- openbsd-compat/bsd-nextstep.c | 6 +- openbsd-compat/bsd-nextstep.h | 23 +- openbsd-compat/bsd-snprintf.c | 557 +++++++++++--------------- openbsd-compat/bsd-snprintf.h | 6 +- openbsd-compat/bsd-waitpid.c | 11 +- openbsd-compat/bsd-waitpid.h | 4 +- openbsd-compat/fake-gai-errnos.h | 11 +- openbsd-compat/fake-getaddrinfo.c | 83 ++-- openbsd-compat/fake-getnameinfo.c | 37 +- openbsd-compat/fake-getnameinfo.h | 6 +- openbsd-compat/port-aix.c | 15 +- openbsd-compat/port-irix.c | 20 +- openbsd-compat/port-irix.h | 11 +- openbsd-compat/vis.c | 1 + 23 files changed, 868 insertions(+), 942 deletions(-) (limited to 'openbsd-compat/bsd-cray.h') diff --git a/ChangeLog b/ChangeLog index b79be01f5..b1adb6ed1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,7 @@ - (djm) Remove IPv4 by default hack now that we can specify AF in config - (djm) Tidy and trim TODO - (djm) Sync openbsd-compat/ with OpenBSD CVS head + - (djm) Big KNF on openbsd-compat/ 20030517 - (bal) strcat -> strlcat on openbsd-compat/realpath.c (rev 1.8 OpenBSD) @@ -1572,4 +1573,4 @@ save auth method before monitor_reset_key_state(); bugzilla bug #284; ok provos@ -$Id: ChangeLog,v 1.2738 2003/05/18 12:24:09 djm Exp $ +$Id: ChangeLog,v 1.2739 2003/05/18 14:13:38 djm Exp $ diff --git a/openbsd-compat/bsd-arc4random.c b/openbsd-compat/bsd-arc4random.c index dd08130d5..5f890968e 100644 --- a/openbsd-compat/bsd-arc4random.c +++ b/openbsd-compat/bsd-arc4random.c @@ -25,7 +25,7 @@ #include "includes.h" #include "log.h" -RCSID("$Id: bsd-arc4random.c,v 1.6 2003/03/17 05:13:53 djm Exp $"); +RCSID("$Id: bsd-arc4random.c,v 1.7 2003/05/18 14:13:38 djm Exp $"); #ifndef HAVE_ARC4RANDOM @@ -70,6 +70,7 @@ void arc4random_stir(void) fatal("Couldn't obtain random bytes (error %ld)", ERR_get_error()); RC4_set_key(&rc4, sizeof(rand_buf), rand_buf); + RC4(&rc4, sizeof(rand_buf), rand_buf, rand_buf); memset(rand_buf, 0, sizeof(rand_buf)); rc4_ready = REKEY_BYTES; diff --git a/openbsd-compat/bsd-cray.c b/openbsd-compat/bsd-cray.c index b04f31004..bff0fea3a 100644 --- a/openbsd-compat/bsd-cray.c +++ b/openbsd-compat/bsd-cray.c @@ -1,5 +1,5 @@ /* - * $Id: bsd-cray.c,v 1.10 2003/05/02 21:32:56 dtucker Exp $ + * $Id: bsd-cray.c,v 1.11 2003/05/18 14:13:38 djm Exp $ * * bsd-cray.c * @@ -67,10 +67,10 @@ extern ServerOptions options; -char cray_tmpdir[TPATHSIZ+1]; /* job TMPDIR path */ +char cray_tmpdir[TPATHSIZ + 1]; /* job TMPDIR path */ -struct sysv sysv; /* system security structure */ -struct usrv usrv; /* user security structure */ +struct sysv sysv; /* system security structure */ +struct usrv usrv; /* user security structure */ /* * Functions. @@ -86,39 +86,40 @@ int cray_access_denied(char *); void cray_login_failure(char *username, int errcode) { - struct udb *ueptr; /* UDB pointer for username */ - ia_failure_t fsent; /* ia_failure structure */ + struct udb *ueptr; /* UDB pointer for username */ + ia_failure_t fsent; /* ia_failure structure */ ia_failure_ret_t fret; /* ia_failure return stuff */ - struct jtab jtab; /* job table structure */ - int jid = 0; /* job id */ + struct jtab jtab; /* job table structure */ + int jid = 0; /* job id */ - if ((jid = getjtab(&jtab)) < 0) { + if ((jid = getjtab(&jtab)) < 0) debug("cray_login_failure(): getjtab error"); - } + getsysudb(); - if ((ueptr = getudbnam(username)) == UDB_NULL) { + if ((ueptr = getudbnam(username)) == UDB_NULL) debug("cray_login_failure(): getudbname() returned NULL"); - } endudb(); - fsent.revision = 0; - fsent.uname = username; - fsent.host = (char *)get_canonical_hostname(options.verify_reverse_mapping); - fsent.ttyn = "sshd"; - fsent.caller = IA_SSHD; - fsent.flags = IA_INTERACTIVE; - fsent.ueptr = ueptr; - fsent.jid = jid; - fsent.errcode = errcode; - fsent.pwdp = NULL; - fsent.exitcode = 0; /* dont exit in ia_failure() */ - - fret.revision = 0; - fret.normal = 0; + + memset(&fsent, '\0', sizeof(fsent)); + fsent.revision = 0; + fsent.uname = username; + fsent.host = (char *)get_canonical_hostname(options.verify_reverse_mapping); + fsent.ttyn = "sshd"; + fsent.caller = IA_SSHD; + fsent.flags = IA_INTERACTIVE; + fsent.ueptr = ueptr; + fsent.jid = jid; + fsent.errcode = errcode; + fsent.pwdp = NULL; + fsent.exitcode = 0; /* dont exit in ia_failure() */ + + fret.revision = 0; + fret.normal = 0; /* * Call ia_failure because of an login failure. */ - ia_failure(&fsent,&fret); + ia_failure(&fsent, &fret); } /* @@ -127,19 +128,20 @@ cray_login_failure(char *username, int errcode) int cray_access_denied(char *username) { - struct udb *ueptr; /* UDB pointer for username */ - int errcode; /* IA errorcode */ + struct udb *ueptr; /* UDB pointer for username */ + int errcode; /* IA errorcode */ errcode = 0; getsysudb(); - if ((ueptr = getudbnam(username)) == UDB_NULL) { + if ((ueptr = getudbnam(username)) == UDB_NULL) debug("cray_login_failure(): getudbname() returned NULL"); - } endudb(); - if (ueptr && ueptr->ue_disabled) + + if (ueptr != NULL && ueptr->ue_disabled) errcode = IA_DISABLED; if (errcode) cray_login_failure(username, errcode); + return (errcode); } @@ -158,316 +160,284 @@ cray_setup (uid_t uid, char *username, const char *command) extern struct udb *getudb(); extern char *setlimits(); - int err; /* error return */ - time_t system_time; /* current system clock */ - time_t expiration_time; /* password expiration time */ - int maxattempts; /* maximum no. of failed login attempts */ - int SecureSys; /* unicos security flag */ - int minslevel = 0; /* system minimum security level */ - int i, j; - int valid_acct = -1; /* flag for reading valid acct */ - char acct_name[MAXACID] = { "" }; /* used to read acct name */ - struct jtab jtab; /* Job table struct */ - struct udb ue; /* udb entry for logging-in user */ - struct udb *up; /* pointer to UDB entry */ - struct secstat secinfo; /* file security attributes */ - struct servprov init_info; /* used for sesscntl() call */ - int jid; /* job ID */ - int pid; /* process ID */ - char *sr; /* status return from setlimits() */ - char *ttyn = NULL; /* ttyname or command name*/ - char hostname[MAXHOSTNAMELEN]; - passwd_t pwdacm, - pwddialup, - pwdudb, - pwdwal, - pwddce; /* passwd stuff for ia_user */ - ia_user_ret_t uret; /* stuff returned from ia_user */ - ia_user_t usent; /* ia_user main structure */ - int ia_rcode; /* ia_user return code */ - ia_failure_t fsent; /* ia_failure structure */ + int err; /* error return */ + time_t system_time; /* current system clock */ + time_t expiration_time; /* password expiration time */ + int maxattempts; /* maximum no. of failed login attempts */ + int SecureSys; /* unicos security flag */ + int minslevel = 0; /* system minimum security level */ + int i, j; + int valid_acct = -1; /* flag for reading valid acct */ + char acct_name[MAXACID] = { "" }; /* used to read acct name */ + struct jtab jtab; /* Job table struct */ + struct udb ue; /* udb entry for logging-in user */ + struct udb *up; /* pointer to UDB entry */ + struct secstat secinfo; /* file security attributes */ + struct servprov init_info; /* used for sesscntl() call */ + int jid; /* job ID */ + int pid; /* process ID */ + char *sr; /* status return from setlimits() */ + char *ttyn = NULL; /* ttyname or command name*/ + char hostname[MAXHOSTNAMELEN]; + /* passwd stuff for ia_user */ + passwd_t pwdacm, pwddialup, pwdudb, pwdwal, pwddce; + ia_user_ret_t uret; /* stuff returned from ia_user */ + ia_user_t usent /* ia_user main structure */ + int ia_rcode; /* ia_user return code */ + ia_failure_t fsent; /* ia_failure structure */ ia_failure_ret_t fret; /* ia_failure return stuff */ - ia_success_t ssent; /* ia_success structure */ + ia_success_t ssent; /* ia_success structure */ ia_success_ret_t sret; /* ia_success return stuff */ - int ia_mlsrcode; /* ia_mlsuser return code */ - int secstatrc; /* [f]secstat return code */ + int ia_mlsrcode; /* ia_mlsuser return code */ + int secstatrc; /* [f]secstat return code */ if (SecureSys = (int)sysconf(_SC_CRAY_SECURE_SYS)) { getsysv(&sysv, sizeof(struct sysv)); minslevel = sysv.sy_minlvl; - if (getusrv(&usrv) < 0) { - debug("getusrv() failed, errno = %d",errno); - exit(1); - } + if (getusrv(&usrv) < 0) + fatal("getusrv() failed, errno = %d", errno); } hostname[0] = '\0'; - strncpy(hostname, + strlcpy(hostname, (char *)get_canonical_hostname(options.verify_reverse_mapping), MAXHOSTNAMELEN); - /* - * Fetch user's UDB entry. - */ - getsysudb(); - if ((up = getudbnam(username)) == UDB_NULL) { - debug("cannot fetch user's UDB entry"); - exit(1); - } - - /* - * Prevent any possible fudging so perform a data - * safety check and compare the supplied uid against - * the udb's uid. - */ - if (up->ue_uid != uid) { - debug("IA uid missmatch"); - exit(1); - } + /* + * Fetch user's UDB entry. + */ + getsysudb(); + if ((up = getudbnam(username)) == UDB_NULL) + fatal("cannot fetch user's UDB entry"); + + /* + * Prevent any possible fudging so perform a data + * safety check and compare the supplied uid against + * the udb's uid. + */ + if (up->ue_uid != uid) + fatal("IA uid missmatch"); endudb(); - if ((jid = getjtab (&jtab)) < 0) { + if ((jid = getjtab(&jtab)) < 0) { debug("getjtab"); - return -1; + return(-1); } pid = getpid(); ttyn = ttyname(0); if (SecureSys) { - if (ttyn) { + if (ttyn != NULL) secstatrc = secstat(ttyn, &secinfo); - } else { + else secstatrc = fsecstat(1, &secinfo); - } - if (secstatrc == 0) { + + if (secstatrc == 0) debug("[f]secstat() successful"); - } else { - debug("[f]secstat() error, rc = %d", secstatrc); - exit(1); - } + else + fatal("[f]secstat() error, rc = %d", secstatrc); } if ((ttyn == NULL) && ((char *)command != NULL)) ttyn = (char *)command; - /* - * Initialize all structures to call ia_user - */ - usent.revision = 0; - usent.uname = username; - usent.host = hostname; - usent.ttyn = ttyn; - usent.caller = IA_SSHD; - usent.pswdlist = &pwdacm; - usent.ueptr = &ue; - usent.flags = IA_INTERACTIVE | IA_FFLAG; - pwdacm.atype = IA_SECURID; - pwdacm.pwdp = NULL; - pwdacm.next = &pwdudb; - - pwdudb.atype = IA_UDB; - pwdudb.pwdp = NULL; - pwdudb.next = &pwddce; - - pwddce.atype = IA_DCE; - pwddce.pwdp = NULL; - pwddce.next = &pwddialup; - - pwddialup.atype = IA_DIALUP; - pwddialup.pwdp = NULL; - /* pwddialup.next = &pwdwal; */ - pwddialup.next = NULL; - - pwdwal.atype = IA_WAL; - pwdwal.pwdp = NULL; - pwdwal.next = NULL; - - uret.revision = 0; - uret.pswd = NULL; - uret.normal = 0; - - ia_rcode = ia_user(&usent, &uret); - - switch (ia_rcode) { - /* - * These are acceptable return codes from ia_user() - */ - case IA_UDBWEEK: /* Password Expires in 1 week */ - expiration_time = ue.ue_pwage.time + ue.ue_pwage.maxage; - printf ("WARNING - your current password will expire %s\n", - ctime((const time_t *)&expiration_time)); - break; - case IA_UDBEXPIRED: - if (ttyname(0) != NULL) { - /* Force a password change */ - printf("Your password has expired; Choose a new one.\n"); - execl("/bin/passwd", "passwd", username, 0); - exit(9); - } - - break; - case IA_NORMAL: /* Normal Return Code */ - break; - case IA_BACKDOOR: - strcpy(ue.ue_name, "root"); - strcpy(ue.ue_passwd, ""); - strcpy(ue.ue_dir, "/"); - strcpy(ue.ue_shell, "/bin/sh"); - strcpy(ue.ue_age, ""); - strcpy(ue.ue_comment, ""); - strcpy(ue.ue_loghost, ""); - strcpy(ue.ue_logline, ""); - ue.ue_uid=-1; - ue.ue_nice[UDBRC_INTER]=0; - for (i=0;i PERMIT_NO) - break; /* Accept root login */ - default: - /* - * These are failed return codes from ia_user() - */ - switch (ia_rcode) - { - case IA_BADAUTH: - printf ("Bad authorization, access denied.\n"); - break; - case IA_DIALUPERR: - break; - case IA_DISABLED: - printf ("Your login has been disabled. Contact the system "); - printf ("administrator for assistance.\n"); - break; - case IA_GETSYSV: - printf ("getsysv() failed - errno = %d\n", errno); - break; - case IA_LOCALHOST: - break; - case IA_MAXLOGS: - printf ("Maximum number of failed login attempts exceeded.\n"); - printf ("Access denied.\n"); - break; - case IA_NOPASS: - break; - case IA_PUBLIC: - break; - case IA_SECURIDERR: - break; - case IA_CONSOLE: - break; - case IA_TRUSTED: - break; - case IA_UDBERR: - break; - case IA_UDBPWDNULL: - /* - * NULL password not allowed on MLS systems - */ - if (SecureSys) { - printf("NULL Password not allowed on MLS systems.\n"); - } - break; - case IA_UNKNOWN: - break; - case IA_UNKNOWNYP: - break; - case IA_WALERR: - break; - default: - /* nothing special */ - ; - } /* 2. switch (ia_rcode) */ - /* - * Authentication failed. - */ - printf("sshd: Login incorrect, (0%o)\n", - ia_rcode-IA_ERRORCODE); - - /* - * Initialize structure for ia_failure - * which will exit. - */ - fsent.revision = 0; - fsent.uname = username; - fsent.host = hostname; - fsent.ttyn = ttyn; - fsent.caller = IA_SSHD; - fsent.flags = IA_INTERACTIVE; - fsent.ueptr = &ue; - fsent.jid = jid; - fsent.errcode = ia_rcode; - fsent.pwdp = uret.pswd; - fsent.exitcode = 1; - - fret.revision = 0; - fret.normal = 0; - - /* - * Call ia_failure because of an IA failure. - * There is no return because ia_failure exits. - */ - - ia_failure(&fsent,&fret); - - exit(1); - } /* 1. switch (ia_rcode) */ + /* + * Initialize all structures to call ia_user + */ + usent.revision = 0; + usent.uname = username; + usent.host = hostname; + usent.ttyn = ttyn; + usent.caller = IA_SSHD; + usent.pswdlist = &pwdacm; + usent.ueptr = &ue; + usent.flags = IA_INTERACTIVE | IA_FFLAG; + pwdacm.atype = IA_SECURID; + pwdacm.pwdp = NULL; + pwdacm.next = &pwdudb; + + pwdudb.atype = IA_UDB; + pwdudb.pwdp = NULL; + pwdudb.next = &pwddce; + + pwddce.atype = IA_DCE; + pwddce.pwdp = NULL; + pwddce.next = &pwddialup; + + pwddialup.atype = IA_DIALUP; + pwddialup.pwdp = NULL; + /* pwddialup.next = &pwdwal; */ + pwddialup.next = NULL; + + pwdwal.atype = IA_WAL; + pwdwal.pwdp = NULL; + pwdwal.next = NULL; + + uret.revision = 0; + uret.pswd = NULL; + uret.normal = 0; + + ia_rcode = ia_user(&usent, &uret); + switch (ia_rcode) { + /* + * These are acceptable return codes from ia_user() + */ + case IA_UDBWEEK: /* Password Expires in 1 week */ + expiration_time = ue.ue_pwage.time + ue.ue_pwage.maxage; + printf ("WARNING - your current password will expire %s\n", + ctime((const time_t *)&expiration_time)); + break; + case IA_UDBEXPIRED: + if (ttyname(0) != NULL) { + /* Force a password change */ + printf("Your password has expired; Choose a new one.\n"); + execl("/bin/passwd", "passwd", username, 0); + exit(9); + } + break; + case IA_NORMAL: /* Normal Return Code */ + break; + case IA_BACKDOOR: + /* XXX: can we memset it to zero here so save some of this */ + strlcpy(ue.ue_name, "root", sizeof(ue.ue_name)); + strlcpy(ue.ue_dir, "/", sizeof(ue.ue_dir)); + strlcpy(ue.ue_shell, "/bin/sh", sizeof(ue.ue_shell)); + + ue.ue_passwd[0] = '\0'; + ue.ue_age[0] = '\0'; + ue.ue_comment[0] = '\0'; + ue.ue_loghost[0] = '\0'; + ue.ue_logline[0] = '\0'; + + ue.ue_uid = -1; + ue.ue_nice[UDBRC_INTER] = 0; + + for (i = 0; i < MAXVIDS; i++) + ue.ue_gids[i] = 0; + + ue.ue_logfails = 0; + ue.ue_minlvl = ue.ue_maxlvl = ue.ue_deflvl = minslevel; + ue.ue_defcomps = 0; + ue.ue_comparts = 0; + ue.ue_permits = 0; + ue.ue_trap = 0; + ue.ue_disabled = 0; + ue.ue_logtime = 0; + break; + case IA_CONSOLE: /* Superuser not from Console */ + case IA_TRUSTED: /* Trusted user */ + if (options.permit_root_login > PERMIT_NO) + break; /* Accept root login */ + default: + /* + * These are failed return codes from ia_user() + */ + switch (ia_rcode) + { + case IA_BADAUTH: + printf("Bad authorization, access denied.\n"); + break; + case IA_DISABLED: + printf("Your login has been disabled. Contact the system "); + printf("administrator for assistance.\n"); + break; + case IA_GETSYSV: + printf("getsysv() failed - errno = %d\n", errno); + break; + case IA_MAXLOGS: + printf("Maximum number of failed login attempts exceeded.\n"); + printf("Access denied.\n"); + break; + case IA_UDBPWDNULL: + if (SecureSys) + printf("NULL Password not allowed on MLS systems.\n"); + break; + default: + break; + } + + /* + * Authentication failed. + */ + printf("sshd: Login incorrect, (0%o)\n", + ia_rcode-IA_ERRORCODE); + + /* + * Initialize structure for ia_failure + * which will exit. + */ + fsent.revision = 0; + fsent.uname = username; + fsent.host = hostname; + fsent.ttyn = ttyn; + fsent.caller = IA_SSHD; + fsent.flags = IA_INTERACTIVE; + fsent.ueptr = &ue; + fsent.jid = jid; + fsent.errcode = ia_rcode; + fsent.pwdp = uret.pswd; + fsent.exitcode = 1; + + fret.revision = 0; + fret.normal = 0; + + /* + * Call ia_failure because of an IA failure. + * There is no return because ia_failure exits. + */ + ia_failure(&fsent, &fret); + + exit(1); + } + ia_mlsrcode = IA_NORMAL; if (SecureSys) { debug("calling ia_mlsuser()"); - ia_mlsrcode = ia_mlsuser (&ue, &secinfo, &usrv, NULL, 0); + ia_mlsrcode = ia_mlsuser(&ue, &secinfo, &usrv, NULL, 0); } if (ia_mlsrcode != IA_NORMAL) { printf("sshd: Login incorrect, (0%o)\n", - ia_mlsrcode-IA_ERRORCODE); + ia_mlsrcode-IA_ERRORCODE); /* - * Initialize structure for ia_failure - * which will exit. - */ + * Initialize structure for ia_failure + * which will exit. + */ fsent.revision = 0; - fsent.uname = username; - fsent.host = hostname; - fsent.ttyn = ttyn; - fsent.caller = IA_SSHD; - fsent.flags = IA_INTERACTIVE; - fsent.ueptr = &ue; - fsent.jid = jid; - fsent.errcode = ia_mlsrcode; - fsent.pwdp = uret.pswd; + fsent.uname = username; + fsent.host = hostname; + fsent.ttyn = ttyn; + fsent.caller = IA_SSHD; + fsent.flags = IA_INTERACTIVE; + fsent.ueptr = &ue; + fsent.jid = jid; + fsent.errcode = ia_mlsrcode; + fsent.pwdp = uret.pswd; fsent.exitcode = 1; - fret.revision = 0; - fret.normal = 0; + fret.revision = 0; + fret.normal = 0; /* - * Call ia_failure because of an IA failure. - * There is no return because ia_failure exits. - */ + * Call ia_failure because of an IA failure. + * There is no return because ia_failure exits. + */ ia_failure(&fsent,&fret); exit(1); } - /* Provide login status information */ - if (options.print_lastlog && ue.ue_logtime != 0) { - printf("Last successful login was : %.*s ", - 19, (char *)ctime(&ue.ue_logtime)); - - if (*ue.ue_loghost != '\0') - printf("from %.*s\n", sizeof(ue.ue_loghost), ue.ue_loghost); - - else printf("on %.*s\n", sizeof(ue.ue_logline), ue.ue_logline); - - if ( SecureSys && (ue.ue_logfails != 0)) - printf(" followed by %d failed attempts\n", ue.ue_logfails); - } - - + /* Provide login status information */ + if (options.print_lastlog && ue.ue_logtime != 0) { + printf("Last successful login was : %.*s ", 19, + (char *)ctime(&ue.ue_logtime)); + + if (*ue.ue_loghost != '\0') { + printf("from %.*s\n", sizeof(ue.ue_loghost), + ue.ue_loghost); + } else { + printf("on %.*s\n", sizeof(ue.ue_logline), + ue.ue_logline); + } + + if (SecureSys && (ue.ue_logfails != 0)) { + printf(" followed by %d failed attempts\n", + ue.ue_logfails); + } + } + /* * Call ia_success to process successful I/A. */ @@ -481,109 +451,116 @@ cray_setup (uid_t uid, char *username, const char *command) ssent.jid = jid; ssent.errcode = ia_rcode; ssent.us = NULL; - ssent.time = 1; /* Set ue_logtime */ + ssent.time = 1; /* Set ue_logtime */ sret.revision = 0; sret.normal = 0; - ia_success(&ssent,&sret); + ia_success(&ssent, &sret); - /* - * Query for account, iff > 1 valid acid & askacid permbit - */ - if (((ue.ue_permbits & PERMBITS_ACCTID) || - (ue.ue_acids[0] >= 0) && (ue.ue_acids[1] >= 0)) && - ue.ue_permbits & PERMBITS_ASKACID) { + /* + * Query for account, iff > 1 valid acid & askacid permbit + */ + if (((ue.ue_permbits & PERMBITS_ACCTID) || + (ue.ue_acids[0] >= 0) && (ue.ue_acids[1] >= 0)) && + ue.ue_permbits & PERMBITS_ASKACID) { if (ttyname(0) != NULL) { - debug("cray_setup: ttyname true case, %.100s", ttyname); - while (valid_acct == -1) { - printf("Account (? for available accounts)" - " [%s]: ", acid2nam(ue.ue_acids[0])); - gets(acct_name); - switch (acct_name[0]) { - case EOF: - exit(0); - break; - case '\0': - valid_acct = ue.ue_acids[0]; - strcpy(acct_name, acid2nam(valid_acct)); - break; - case '?': - /* Print the list 3 wide */ - for (i = 0, j = 0; i < MAXVIDS; i++) { - if (ue.ue_acids[i] == -1) { - printf("\n"); - break; - } - if (++j == 4) { - j = 1; - printf("\n"); - } - printf(" %s", - acid2nam(ue.ue_acids[i])); - } - if (ue.ue_permbits & PERMBITS_ACCTID) - printf("\"acctid\" permbit also allows" - " you to select any valid " - "account name.\n"); - printf("\n"); - break; - default: - if ((valid_acct = nam2acid(acct_name)) == -1) printf("Account id not found for" - " account name \"%s\"\n\n", - acct_name); - break; - } - /* - * If an account was given, search the user's - * acids array to verify they can use this account. - */ - if ((valid_acct != -1) && - !(ue.ue_permbits & PERMBITS_ACCTID)) { - for (i = 0; i < MAXVIDS; i++) { - if (ue.ue_acids[i] == -1) - break; - if (valid_acct == ue.ue_acids[i]) - break; - } - if (i == MAXVIDS || - ue.ue_acids[i] == -1) { - fprintf(stderr, "Cannot set" - " account name to " - "\"%s\", permission " - "denied\n\n", acct_name); - valid_acct = -1; - } - } - } + debug("cray_setup: ttyname true case, %.100s", ttyname); + while (valid_acct == -1) { + printf("Account (? for available accounts)" + " [%s]: ", acid2nam(ue.ue_acids[0])); + fgets(acct_name, MAXACID, stdin); + switch (acct_name[0]) { + case EOF: + exit(0); + break; + case '\0': + valid_acct = ue.ue_acids[0]; + strlcpy(acct_name, acid2nam(valid_acct), MAXACID); + break; + case '?': + /* Print the list 3 wide */ + for (i = 0, j = 0; i < MAXVIDS; i++) { + if (ue.ue_acids[i] == -1) { + printf("\n"); + break; + } + if (++j == 4) { + j = 1; + printf("\n"); + } + printf(" %s", + acid2nam(ue.ue_acids[i])); + } + if (ue.ue_permbits & PERMBITS_ACCTID) { + printf("\"acctid\" permbit also allows" + " you to select any valid " + "account name.\n"); + } + printf("\n"); + break; + default: + valid_acct = nam2acid(acct_name); + if (valid_acct == -1) { + printf( + "Account id not found for" + " account name \"%s\"\n\n", + acct_name); + break; + } + /* + * If an account was given, search the user's + * acids array to verify they can use this account. + */ + if ((valid_acct != -1) && + !(ue.ue_permbits & PERMBITS_ACCTID)) { + for (i = 0; i < MAXVIDS; i++) { + if (ue.ue_acids[i] == -1) + break; + if (valid_acct == ue.ue_acids[i]) + break; + } + if (i == MAXVIDS || + ue.ue_acids[i] == -1) { + fprintf(stderr, "Cannot set" + " account name to " + "\"%s\", permission " + "denied\n\n", acct_name); + valid_acct = -1; + } + } + } + } else { + /* + * The client isn't connected to a terminal and can't + * respond to an acid prompt. Use default acid. + */ + debug("cray_setup: ttyname false case, %.100s", + ttyname); + valid_acct = ue.ue_acids[0]; + } } else { /* - * The client isn't connected to a terminal and can't - * respond to an acid prompt. Use default acid. + * The user doesn't have the askacid permbit set or + * only has one valid account to use. */ - debug("cray_setup: ttyname false case, %.100s", ttyname); valid_acct = ue.ue_acids[0]; } - } else { - /* - * The user doesn't have the askacid permbit set or - * only has one valid account to use. - */ - valid_acct = ue.ue_acids[0]; - } - if (acctid(0, valid_acct) < 0) { - printf ("Bad account id: %d\n", valid_acct); - exit(1); - } - -/* set up shares and quotas */ -/* Now set shares, quotas, limits, including CPU time for the (interactive) - * job and process, and set up permissions (for chown etc), etc. - */ + if (acctid(0, valid_acct) < 0) { + printf ("Bad account id: %d\n", valid_acct); + exit(1); + } + + /* + * Now set shares, quotas, limits, including CPU time for the + * (interactive) job and process, and set up permissions + * (for chown etc), etc. + */ if (setshares(ue.ue_uid, valid_acct, printf, 0, 0)) { - printf("Unable to give %d shares to <%s>(%d/%d)\n", ue.ue_shares, ue.ue_name, ue.ue_uid, valid_acct); + printf("Unable to give %d shares to <%s>(%d/%d)\n", + ue.ue_shares, ue.ue_name, ue.ue_uid, valid_acct); exit(1); - } + } sr = setlimits(username, C_PROC, pid, UDBRC_INTER); if (sr != NULL) { @@ -596,17 +573,15 @@ cray_setup (uid_t uid, char *username, const char *command) exit(1); } /* - * Place the service provider information into + * Place the service provider information into * the session table (Unicos) or job table (Unicos/mk). * There exist double defines for the job/session table in * unicos/mk (jtab.h) so no need for a compile time switch. */ - bzero((char *)&init_info, sizeof(struct servprov)); - init_info.s_sessinit.si_id = URM_SPT_LOGIN; + memset(&init_info, '\0', sizeof(init_info)); + init_info.s_sessinit.si_id = URM_SPT_LOGIN; init_info.s_sessinit.si_pid = getpid(); init_info.s_sessinit.si_sid = jid; - init_info.s_routing.seqno = 0; - init_info.s_routing.iadrs = 0; sesscntl(0, S_SETSERVPO, (int)&init_info); /* @@ -619,7 +594,7 @@ cray_setup (uid_t uid, char *username, const char *command) } } - return(0); + return (0); } /* @@ -632,10 +607,10 @@ void drop_cray_privs() { #if defined(_SC_CRAY_PRIV_SU) - priv_proc_t* privstate; - int result; - extern int priv_set_proc(); - extern priv_proc_t* priv_init_proc(); + priv_proc_t *privstate; + int result; + extern int priv_set_proc(); + extern priv_proc_t *priv_init_proc(); /* * If ether of theses two flags are not set @@ -663,15 +638,17 @@ drop_cray_privs() usrv.sv_intcat = TFM_SYSTEM; usrv.sv_valcat |= (TFM_SYSTEM | TFM_SYSFILE); - if (setusrv(&usrv) < 0) + if (setusrv(&usrv) < 0) { fatal("%s(%d): setusrv(): %s", __FILE__, __LINE__, strerror(errno)); + } if ((privstate = priv_init_proc()) != NULL) { result = priv_set_proc(privstate); - if (result != 0 ) + if (result != 0 ) { fatal("%s(%d): priv_set_proc(): %s", __FILE__, __LINE__, strerror(errno)); + } priv_free_proc(privstate); } debug ("Privileges should be cleared..."); @@ -692,6 +669,7 @@ cray_retain_utmp(struct utmp *ut, int pid) struct utmp utmp; if ((fd = open(UTMP_FILE, O_RDONLY)) != -1) { + /* XXX use atomicio */ while (read(fd, (char *)&utmp, sizeof(utmp)) == sizeof(utmp)) { if (pid == utmp.ut_pid) { ut->ut_jid = utmp.ut_jid; @@ -702,9 +680,8 @@ cray_retain_utmp(struct utmp *ut, int pid) } } close(fd); - } - else - fatal("Unable to open utmp file"); + } else + fatal("Unable to open utmp file"); } /* @@ -717,11 +694,9 @@ cray_retain_utmp(struct utmp *ut, int pid) void cray_delete_tmpdir(char *login, int jid, uid_t uid) { - int child; static char jtmp[TPATHSIZ]; struct stat statbuf; - int c; - int wstat; + int child, c, wstat; for (c = 'a'; c <= 'z'; c++) { snprintf(jtmp, TPATHSIZ, "%s/jtmp.%06d%c", JTMPDIR, jid, c); diff --git a/openbsd-compat/bsd-cray.h b/openbsd-compat/bsd-cray.h index d2489f4bf..433144f6f 100644 --- a/openbsd-compat/bsd-cray.h +++ b/openbsd-compat/bsd-cray.h @@ -1,5 +1,5 @@ /* - * $Id: bsd-cray.h,v 1.8 2003/05/02 13:42:25 dtucker Exp $ + * $Id: bsd-cray.h,v 1.9 2003/05/18 14:13:39 djm Exp $ * * bsd-cray.h * @@ -38,23 +38,26 @@ #define _BSD_CRAY_H #ifdef _UNICOS -void cray_init_job(struct passwd *); /* init cray job */ -void cray_job_termination_handler(int); /* process end of job signal */ -void cray_login_failure(char *username, int errcode); -int cray_access_denied(char *username); + +void cray_init_job(struct passwd *); +void cray_job_termination_handler(int); +void cray_login_failure(char *, int ); +int cray_access_denied(char *); #define CUSTOM_FAILED_LOGIN 1 -void record_failed_login(const char *user, const char *ttyname); -extern char cray_tmpdir[]; /* cray tmpdir */ +void record_failed_login(const char *, const char *); +extern char cray_tmpdir[]; + #ifndef IA_SSHD -#define IA_SSHD IA_LOGIN +# define IA_SSHD IA_LOGIN #endif #ifndef MAXHOSTNAMELEN -#define MAXHOSTNAMELEN 64 +# define MAXHOSTNAMELEN 64 #endif #ifndef _CRAYT3E -#include -#define TIOCGPGRP (tIOC|20) -#endif +# include +# define TIOCGPGRP (tIOC|20) #endif +#endif /* UNICOS */ + #endif /* _BSD_CRAY_H */ diff --git a/openbsd-compat/bsd-cygwin_util.c b/openbsd-compat/bsd-cygwin_util.c index 0fa5964bc..012ba4c75 100644 --- a/openbsd-compat/bsd-cygwin_util.c +++ b/openbsd-compat/bsd-cygwin_util.c @@ -31,7 +31,7 @@ #include "includes.h" -RCSID("$Id: bsd-cygwin_util.c,v 1.9 2002/11/09 15:59:29 mouring Exp $"); +RCSID("$Id: bsd-cygwin_util.c,v 1.10 2003/05/18 14:13:39 djm Exp $"); #ifdef HAVE_CYGWIN @@ -53,7 +53,8 @@ RCSID("$Id: bsd-cygwin_util.c,v 1.9 2002/11/09 15:59:29 mouring Exp $"); # undef pipe #endif -int binary_open(const char *filename, int flags, ...) +int +binary_open(const char *filename, int flags, ...) { va_list ap; mode_t mode; @@ -61,55 +62,56 @@ int binary_open(const char *filename, int flags, ...) va_start(ap, flags); mode = va_arg(ap, mode_t); va_end(ap); - return open(filename, flags | O_BINARY, mode); + return (open(filename, flags | O_BINARY, mode)); } -int binary_pipe(int fd[2]) +int +binary_pipe(int fd[2]) { int ret = pipe(fd); if (!ret) { - setmode (fd[0], O_BINARY); - setmode (fd[1], O_BINARY); + setmode(fd[0], O_BINARY); + setmode(fd[1], O_BINARY); } - return ret; + return (ret); } #define HAS_CREATE_TOKEN 1 #define HAS_NTSEC_BY_DEFAULT 2 -static int has_capability(int what) +static int +has_capability(int what) { - /* has_capability() basically calls uname() and checks if - specific capabilities of Cygwin can be evaluated from that. - This simplifies the calling functions which only have to ask - for a capability using has_capability() instead of having - to figure that out by themselves. */ static int inited; static int has_create_token; static int has_ntsec_by_default; + /* + * has_capability() basically calls uname() and checks if + * specific capabilities of Cygwin can be evaluated from that. + * This simplifies the calling functions which only have to ask + * for a capability using has_capability() instead of having + * to figure that out by themselves. + */ if (!inited) { struct utsname uts; char *c; if (!uname(&uts)) { - int major_high = 0; - int major_low = 0; - int minor = 0; - int api_major_version = 0; - int api_minor_version = 0; + int major_high = 0, major_low = 0, minor = 0; + int api_major_version = 0, api_minor_version = 0; char *c; sscanf(uts.release, "%d.%d.%d", &major_high, - &major_low, &minor); - c = strchr(uts.release, '('); - if (c) + &major_low, &minor); + if ((c = strchr(uts.release, '(')) != NULL) { sscanf(c + 1, "%d.%d", &api_major_version, - &api_minor_version); + &api_minor_version); + } if (major_high > 1 || (major_high == 1 && (major_low > 3 || - (major_low == 3 && minor >= 2)))) + (major_low == 3 && minor >= 2)))) has_create_token = 1; if (api_major_version > 0 || api_minor_version >= 56) has_ntsec_by_default = 1; @@ -118,14 +120,15 @@ static int has_capability(int what) } switch (what) { case HAS_CREATE_TOKEN: - return has_create_token; + return (has_create_token); case HAS_NTSEC_BY_DEFAULT: - return has_ntsec_by_default; + return (has_ntsec_by_default); } - return 0; + return (0); } -int check_nt_auth(int pwd_authenticated, struct passwd *pw) +int +check_nt_auth(int pwd_authenticated, struct passwd *pw) { /* * The only authentication which is able to change the user @@ -149,34 +152,33 @@ int check_nt_auth(int pwd_authenticated, struct passwd *pw) has_create_token = 0; if (has_capability(HAS_CREATE_TOKEN) && (ntsec_on(cygwin) || - (has_capability(HAS_NTSEC_BY_DEFAULT) && - !ntsec_off(cygwin)))) + (has_capability(HAS_NTSEC_BY_DEFAULT) && + !ntsec_off(cygwin)))) has_create_token = 1; } if (has_create_token < 1 && !pwd_authenticated && geteuid() != pw->pw_uid) - return 0; + return (0); } - return 1; + return (1); } -int check_ntsec(const char *filename) +int +check_ntsec(const char *filename) { char *cygwin; - int allow_ntea = 0; - int allow_ntsec = 0; + int allow_ntea = 0, allow_ntsec = 0; struct statfs fsstat; /* Windows 95/98/ME don't support file system security at all. */ if (!is_winnt) - return 0; + return (0); /* Evaluate current CYGWIN settings. */ cygwin = getenv("CYGWIN"); allow_ntea = ntea_on(cygwin); allow_ntsec = ntsec_on(cygwin) || - (has_capability(HAS_NTSEC_BY_DEFAULT) && - !ntsec_off(cygwin)); + (has_capability(HAS_NTSEC_BY_DEFAULT) && !ntsec_off(cygwin)); /* * `ntea' is an emulation of POSIX attributes. It doesn't support @@ -185,14 +187,14 @@ int check_ntsec(const char *filename) * for security checks. */ if (allow_ntea) - return 1; + return (1); /* * Retrieve file system flags. In Cygwin, file system flags are * copied to f_type which has no meaning in Win32 itself. */ if (statfs(filename, &fsstat)) - return 1; + return (1); /* * Only file systems supporting ACLs are able to set permissions. @@ -200,12 +202,13 @@ int check_ntsec(const char *filename) * ACLs to support POSIX permissions on files. */ if (fsstat.f_type & FS_PERSISTENT_ACLS) - return allow_ntsec; + return (allow_ntsec); - return 0; + return (0); } -void register_9x_service(void) +void +register_9x_service(void) { HINSTANCE kerneldll; DWORD (*RegisterServiceProcess)(DWORD, DWORD); @@ -219,10 +222,10 @@ void register_9x_service(void) */ if (is_winnt) return; - if (! (kerneldll = LoadLibrary("KERNEL32.DLL"))) + if (!(kerneldll = LoadLibrary("KERNEL32.DLL"))) return; - if (! (RegisterServiceProcess = (DWORD (*)(DWORD, DWORD)) - GetProcAddress(kerneldll, "RegisterServiceProcess"))) + if (!(RegisterServiceProcess = (DWORD (*)(DWORD, DWORD)) + GetProcAddress(kerneldll, "RegisterServiceProcess"))) return; RegisterServiceProcess(0, 1); } diff --git a/openbsd-compat/bsd-cygwin_util.h b/openbsd-compat/bsd-cygwin_util.h index af470bdd8..859afbef5 100644 --- a/openbsd-compat/bsd-cygwin_util.h +++ b/openbsd-compat/bsd-cygwin_util.h @@ -1,4 +1,4 @@ -/* $Id: bsd-cygwin_util.h,v 1.7 2002/04/15 22:00:52 stevesk Exp $ */ +/* $Id: bsd-cygwin_util.h,v 1.8 2003/05/18 14:13:39 djm Exp $ */ /* * cygwin_util.c @@ -38,10 +38,10 @@ #include -int binary_open(const char *filename, int flags, ...); +int binary_open(const char *, int , ...); int binary_pipe(int fd[2]); -int check_nt_auth(int pwd_authenticated, struct passwd *pw); -int check_ntsec(const char *filename); +int check_nt_auth(int, struct passwd *); +int check_ntsec(const char *); void register_9x_service(void); #define open binary_open diff --git a/openbsd-compat/bsd-getpeereid.h b/openbsd-compat/bsd-getpeereid.h index 2e9f077f9..771e9cbf9 100644 --- a/openbsd-compat/bsd-getpeereid.h +++ b/openbsd-compat/bsd-getpeereid.h @@ -1,4 +1,28 @@ -/* $Id: bsd-getpeereid.h,v 1.1 2002/09/12 00:33:02 djm Exp $ */ +/* + * Copyright (c) 2002-2003 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-getpeereid.h,v 1.2 2003/05/18 14:13:39 djm Exp $ */ #ifndef _BSD_GETPEEREID_H #define _BSD_GETPEEREID_H diff --git a/openbsd-compat/bsd-misc.c b/openbsd-compat/bsd-misc.c index b8e9996d5..cdc63c24d 100644 --- a/openbsd-compat/bsd-misc.c +++ b/openbsd-compat/bsd-misc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999-2000 Damien Miller. All rights reserved. + * Copyright (c) 1999-2003 Damien Miller. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -25,7 +25,7 @@ #include "includes.h" #include "xmalloc.h" -RCSID("$Id: bsd-misc.c,v 1.12 2003/03/18 18:21:41 tim Exp $"); +RCSID("$Id: bsd-misc.c,v 1.13 2003/05/18 14:13:39 djm Exp $"); /* * NB. duplicate __progname in case it is an alias for argv[0] @@ -41,21 +41,21 @@ char *get_progname(char *argv0) char *p; if (argv0 == NULL) - return "unknown"; /* XXX */ + return ("unknown"); /* XXX */ p = strrchr(argv0, '/'); if (p == NULL) p = argv0; else p++; - return xstrdup(p); + return (xstrdup(p)); #endif } #ifndef HAVE_SETLOGIN int setlogin(const char *name) { - return(0); + return (0); } #endif /* !HAVE_SETLOGIN */ @@ -63,21 +63,21 @@ int setlogin(const char *name) int innetgr(const char *netgroup, const char *host, const char *user, const char *domain) { - return(0); + return (0); } #endif /* HAVE_INNETGR */ #if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) int seteuid(uid_t euid) { - return(setreuid(-1,euid)); + return (setreuid(-1, euid)); } #endif /* !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) */ #if !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) int setegid(uid_t egid) { - return(setresgid(-1,egid,-1)); + return(setresgid(-1, egid, -1)); } #endif /* !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) */ @@ -88,9 +88,9 @@ const char *strerror(int e) extern char *sys_errlist[]; if ((e >= 0) && (e < sys_nerr)) - return(sys_errlist[e]); - else - return("unlisted error"); + return (sys_errlist[e]); + + return ("unlisted error"); } #endif @@ -102,24 +102,25 @@ int utimes(char *filename, struct timeval *tvp) ub.actime = tvp[0].tv_sec; ub.modtime = tvp[1].tv_sec; - return(utime(filename, &ub)); + return (utime(filename, &ub)); } #endif #ifndef HAVE_TRUNCATE -int truncate (const char *path, off_t length) +int truncate(const char *path, off_t length) { int fd, ret, saverrno; fd = open(path, O_WRONLY); if (fd < 0) - return -1; + return (-1); ret = ftruncate(fd, length); saverrno = errno; - (void) close (fd); + close(fd); if (ret == -1) errno = saverrno; + return(ret); } #endif /* HAVE_TRUNCATE */ @@ -131,7 +132,7 @@ int truncate (const char *path, off_t length) int setgroups(size_t size, const gid_t *list) { - return 0; + return (0); } #endif diff --git a/openbsd-compat/bsd-misc.h b/openbsd-compat/bsd-misc.h index 78d9ccdd4..00e508cfc 100644 --- a/openbsd-compat/bsd-misc.h +++ b/openbsd-compat/bsd-misc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999-2000 Damien Miller. All rights reserved. + * Copyright (c) 1999-2003 Damien Miller. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -22,42 +22,41 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* $Id: bsd-misc.h,v 1.7 2003/03/18 18:21:41 tim Exp $ */ +/* $Id: bsd-misc.h,v 1.8 2003/05/18 14:13:39 djm Exp $ */ #ifndef _BSD_MISC_H #define _BSD_MISC_H #include "config.h" -char *get_progname(char *argv0); +char *get_progname(char *); #ifndef HAVE_SETSID #define setsid() setpgrp(0, getpid()) #endif /* !HAVE_SETSID */ #ifndef HAVE_SETENV -int setenv(const char *name, const char *value, int overwrite); +int setenv(const char *, const char *, int); #endif /* !HAVE_SETENV */ #ifndef HAVE_SETLOGIN -int setlogin(const char *name); +int setlogin(const char *); #endif /* !HAVE_SETLOGIN */ #ifndef HAVE_INNETGR -int innetgr(const char *netgroup, const char *host, - const char *user, const char *domain); +int innetgr(const char *, const char *, const char *, const char *); #endif /* HAVE_INNETGR */ #if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) -int seteuid(uid_t euid); +int seteuid(uid_t); #endif /* !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) */ #if !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) -int setegid(uid_t egid); +int setegid(uid_t); #endif /* !defined(HAVE_SETEGID) && defined(HAVE_SETRESGID) */ #if !defined(HAVE_STRERROR) && defined(HAVE_SYS_ERRLIST) && defined(HAVE_SYS_NERR) -const char *strerror(int e); +const char *strerror(int); #endif @@ -69,15 +68,15 @@ struct timeval { } #endif /* HAVE_STRUCT_TIMEVAL */ -int utimes(char *filename, struct timeval *tvp); +int utimes(char *, struct timeval *); #endif /* HAVE_UTIMES */ #ifndef HAVE_TRUNCATE -int truncate (const char *path, off_t length); +int truncate (const char *, off_t); #endif /* HAVE_TRUNCATE */ #if !defined(HAVE_SETGROUPS) && defined(SETGROUPS_NOOP) -int setgroups(size_t size, const gid_t *list); +int setgroups(size_t, const gid_t *); #endif #if !defined(HAVE_NANOSLEEP) && !defined(HAVE_NSLEEP) @@ -87,7 +86,7 @@ struct timespec { long tv_nsec; }; #endif -int nanosleep(const struct timespec *req, struct timespec *rem); +int nanosleep(const struct timespec *, struct timespec *); #endif #endif /* _BSD_MISC_H */ diff --git a/openbsd-compat/bsd-nextstep.c b/openbsd-compat/bsd-nextstep.c index 85b298a48..5b264ab2f 100644 --- a/openbsd-compat/bsd-nextstep.c +++ b/openbsd-compat/bsd-nextstep.c @@ -1,3 +1,5 @@ +/* XXX - author */ + /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -22,7 +24,7 @@ #include "includes.h" -RCSID("$Id: bsd-nextstep.c,v 1.4 2001/03/26 05:35:34 mouring Exp $"); +RCSID("$Id: bsd-nextstep.c,v 1.5 2003/05/18 14:13:39 djm Exp $"); #ifdef HAVE_NEXT #include @@ -40,7 +42,7 @@ posix_wait(int *status) if (status) *status = (int) statusp.w_status; - return wait_pid; + return (wait_pid); } int diff --git a/openbsd-compat/bsd-nextstep.h b/openbsd-compat/bsd-nextstep.h index c6a7019c6..dc5dc7e17 100644 --- a/openbsd-compat/bsd-nextstep.h +++ b/openbsd-compat/bsd-nextstep.h @@ -1,3 +1,5 @@ +/* XXX - author */ + /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -21,7 +23,7 @@ * */ -/* $Id: bsd-nextstep.h,v 1.6 2001/03/19 13:42:22 mouring Exp $ */ +/* $Id: bsd-nextstep.h,v 1.7 2003/05/18 14:13:39 djm Exp $ */ #ifndef _NEXT_POSIX_H #define _NEXT_POSIX_H @@ -37,22 +39,21 @@ #define dirent direct /* Swap out NeXT's BSD wait() for a more POSIX complient one */ -pid_t posix_wait(int *status); +pid_t posix_wait(int *); #define wait(a) posix_wait(a) /* #ifdef wrapped functions that need defining for clean compiling */ pid_t getppid(void); void vhangup(void); -int innetgr(const char *netgroup, const char *host, const char *user, - const char *domain); +int innetgr(const char *, const char *, const char *, const char *); /* TERMCAP */ -int tcgetattr(int fd, struct termios *t); -int tcsetattr(int fd, int opt, const struct termios *t); -int tcsetpgrp(int fd, pid_t pgrp); -speed_t cfgetospeed(const struct termios *t); -speed_t cfgetispeed(const struct termios *t); -int cfsetospeed(struct termios *t, int speed); -int cfsetispeed(struct termios *t, int speed); +int tcgetattr(int, struct termios *); +int tcsetattr(int, int, const struct termios *); +int tcsetpgrp(int, pid_t); +speed_t cfgetospeed(const struct termios *); +speed_t cfgetispeed(const struct termios *); +int cfsetospeed(struct termios *, int); +int cfsetispeed(struct termios *, int); #endif /* HAVE_NEXT */ #endif /* _NEXT_POSIX_H */ diff --git a/openbsd-compat/bsd-snprintf.c b/openbsd-compat/bsd-snprintf.c index 2f82180d1..e4d8a439a 100644 --- a/openbsd-compat/bsd-snprintf.c +++ b/openbsd-compat/bsd-snprintf.c @@ -58,7 +58,7 @@ #include "includes.h" -RCSID("$Id: bsd-snprintf.c,v 1.6 2003/04/01 11:31:56 djm Exp $"); +RCSID("$Id: bsd-snprintf.c,v 1.7 2003/05/18 14:13:39 djm Exp $"); #if defined(BROKEN_SNPRINTF) /* For those with broken snprintf() */ # undef HAVE_SNPRINTF @@ -72,15 +72,15 @@ dopr(char *buffer, size_t maxlen, const char *format, va_list args); static void fmtstr(char *buffer, size_t *currlen, size_t maxlen, char *value, int flags, - int min, int max); + int min, int max); static void fmtint(char *buffer, size_t *currlen, size_t maxlen, long value, int base, - int min, int max, int flags); + int min, int max, int flags); static void fmtfp(char *buffer, size_t *currlen, size_t maxlen, long double fvalue, - int min, int max, int flags); + int min, int max, int flags); static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c); @@ -121,15 +121,10 @@ dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c); static void dopr(char *buffer, size_t maxlen, const char *format, va_list args) { - char *strvalue; - char ch; + char *strvalue, ch; long value; long double fvalue; - int min = 0; - int max = -1; - int state = DP_S_DEFAULT; - int flags = 0; - int cflags = 0; + int min = 0, max = -1, state = DP_S_DEFAULT, flags = 0, cflags = 0; size_t currlen = 0; ch = *format++; @@ -139,224 +134,224 @@ dopr(char *buffer, size_t maxlen, const char *format, va_list args) state = DP_S_DONE; switch(state) { - case DP_S_DEFAULT: - if (ch == '%') - state = DP_S_FLAGS; - else - dopr_outch(buffer, &currlen, maxlen, ch); + case DP_S_DEFAULT: + if (ch == '%') + state = DP_S_FLAGS; + else + dopr_outch(buffer, &currlen, maxlen, ch); + ch = *format++; + break; + case DP_S_FLAGS: + switch (ch) { + case '-': + flags |= DP_F_MINUS; ch = *format++; break; - case DP_S_FLAGS: - switch (ch) { - case '-': - flags |= DP_F_MINUS; - ch = *format++; - break; - case '+': - flags |= DP_F_PLUS; - ch = *format++; - break; - case ' ': - flags |= DP_F_SPACE; - ch = *format++; - break; - case '#': - flags |= DP_F_NUM; - ch = *format++; - break; - case '0': - flags |= DP_F_ZERO; - ch = *format++; - break; - default: - state = DP_S_MIN; - break; - } + case '+': + flags |= DP_F_PLUS; + ch = *format++; break; - case DP_S_MIN: - if (isdigit((unsigned char)ch)) { - min = 10*min + char_to_int (ch); - ch = *format++; - } else if (ch == '*') { - min = va_arg (args, int); - ch = *format++; - state = DP_S_DOT; - } else - state = DP_S_DOT; + case ' ': + flags |= DP_F_SPACE; + ch = *format++; break; - case DP_S_DOT: - if (ch == '.') { - state = DP_S_MAX; - ch = *format++; - } else - state = DP_S_MOD; + case '#': + flags |= DP_F_NUM; + ch = *format++; break; - case DP_S_MAX: - if (isdigit((unsigned char)ch)) { - if (max < 0) - max = 0; - max = 10*max + char_to_int(ch); - ch = *format++; - } else if (ch == '*') { - max = va_arg (args, int); - ch = *format++; - state = DP_S_MOD; - } else - state = DP_S_MOD; + case '0': + flags |= DP_F_ZERO; + ch = *format++; break; - case DP_S_MOD: - switch (ch) { - case 'h': - cflags = DP_C_SHORT; - ch = *format++; - break; - case 'l': - cflags = DP_C_LONG; - ch = *format++; - if (ch == 'l') { - cflags = DP_C_LONG_LONG; - ch = *format++; - } - break; - case 'q': - cflags = DP_C_LONG_LONG; - ch = *format++; - break; - case 'L': - cflags = DP_C_LDOUBLE; - ch = *format++; - break; - default: - break; - } - state = DP_S_CONV; + default: + state = DP_S_MIN; break; - case DP_S_CONV: - switch (ch) { - case 'd': - case 'i': - if (cflags == DP_C_SHORT) - value = va_arg(args, int); - else if (cflags == DP_C_LONG) - value = va_arg(args, long int); - else if (cflags == DP_C_LONG_LONG) - value = va_arg (args, long long); - else - value = va_arg (args, int); - fmtint(buffer, &currlen, maxlen, value, 10, min, max, flags); - break; - case 'o': - flags |= DP_F_UNSIGNED; - if (cflags == DP_C_SHORT) - value = va_arg(args, unsigned int); - else if (cflags == DP_C_LONG) - value = va_arg(args, unsigned long int); - else if (cflags == DP_C_LONG_LONG) - value = va_arg(args, unsigned long long); - else - value = va_arg(args, unsigned int); - fmtint(buffer, &currlen, maxlen, value, 8, min, max, flags); - break; - case 'u': - flags |= DP_F_UNSIGNED; - if (cflags == DP_C_SHORT) - value = va_arg(args, unsigned int); - else if (cflags == DP_C_LONG) - value = va_arg(args, unsigned long int); - else if (cflags == DP_C_LONG_LONG) - value = va_arg(args, unsigned long long); - else - value = va_arg(args, unsigned int); - fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags); - break; - case 'X': - flags |= DP_F_UP; - case 'x': - flags |= DP_F_UNSIGNED; - if (cflags == DP_C_SHORT) - value = va_arg(args, unsigned int); - else if (cflags == DP_C_LONG) - value = va_arg(args, unsigned long int); - else if (cflags == DP_C_LONG_LONG) - value = va_arg(args, unsigned long long); - else - value = va_arg(args, unsigned int); - fmtint(buffer, &currlen, maxlen, value, 16, min, max, flags); - break; - case 'f': - if (cflags == DP_C_LDOUBLE) - fvalue = va_arg(args, long double); - else - fvalue = va_arg(args, double); - /* um, floating point? */ - fmtfp(buffer, &currlen, maxlen, fvalue, min, max, flags); - break; - case 'E': - flags |= DP_F_UP; - case 'e': - if (cflags == DP_C_LDOUBLE) - fvalue = va_arg(args, long double); - else - fvalue = va_arg(args, double); - break; - case 'G': - flags |= DP_F_UP; - case 'g': - if (cflags == DP_C_LDOUBLE) - fvalue = va_arg(args, long double); - else - fvalue = va_arg(args, double); - break; - case 'c': - dopr_outch(buffer, &currlen, maxlen, va_arg(args, int)); - break; - case 's': - strvalue = va_arg(args, char *); - if (max < 0) - max = maxlen; /* ie, no max */ - fmtstr(buffer, &currlen, maxlen, strvalue, flags, min, max); - break; - case 'p': - strvalue = va_arg(args, void *); - fmtint(buffer, &currlen, maxlen, (long) strvalue, 16, min, max, flags); - break; - case 'n': - if (cflags == DP_C_SHORT) { - short int *num; - num = va_arg(args, short int *); - *num = currlen; - } else if (cflags == DP_C_LONG) { - long int *num; - num = va_arg(args, long int *); - *num = currlen; - } else if (cflags == DP_C_LONG_LONG) { - long long *num; - num = va_arg(args, long long *); - *num = currlen; - } else { - int *num; - num = va_arg(args, int *); - *num = currlen; - } - break; - case '%': - dopr_outch(buffer, &currlen, maxlen, ch); - break; - case 'w': /* not supported yet, treat as next char */ - ch = *format++; - break; - default: /* Unknown, skip */ - break; + } + break; + case DP_S_MIN: + if (isdigit((unsigned char)ch)) { + min = 10 * min + char_to_int (ch); + ch = *format++; + } else if (ch == '*') { + min = va_arg (args, int); + ch = *format++; + state = DP_S_DOT; + } else + state = DP_S_DOT; + break; + case DP_S_DOT: + if (ch == '.') { + state = DP_S_MAX; + ch = *format++; + } else + state = DP_S_MOD; + break; + case DP_S_MAX: + if (isdigit((unsigned char)ch)) { + if (max < 0) + max = 0; + max = 10 * max + char_to_int(ch); + ch = *format++; + } else if (ch == '*') { + max = va_arg (args, int); + ch = *format++; + state = DP_S_MOD; + } else + state = DP_S_MOD; + break; + case DP_S_MOD: + switch (ch) { + case 'h': + cflags = DP_C_SHORT; + ch = *format++; + break; + case 'l': + cflags = DP_C_LONG; + ch = *format++; + if (ch == 'l') { + cflags = DP_C_LONG_LONG; + ch = *format++; } + break; + case 'q': + cflags = DP_C_LONG_LONG; + ch = *format++; + break; + case 'L': + cflags = DP_C_LDOUBLE; ch = *format++; - state = DP_S_DEFAULT; - flags = cflags = min = 0; - max = -1; break; - case DP_S_DONE: + default: + break; + } + state = DP_S_CONV; + break; + case DP_S_CONV: + switch (ch) { + case 'd': + case 'i': + if (cflags == DP_C_SHORT) + value = va_arg(args, int); + else if (cflags == DP_C_LONG) + value = va_arg(args, long int); + else if (cflags == DP_C_LONG_LONG) + value = va_arg (args, long long); + else + value = va_arg (args, int); + fmtint(buffer, &currlen, maxlen, value, 10, min, max, flags); + break; + case 'o': + flags |= DP_F_UNSIGNED; + if (cflags == DP_C_SHORT) + value = va_arg(args, unsigned int); + else if (cflags == DP_C_LONG) + value = va_arg(args, unsigned long int); + else if (cflags == DP_C_LONG_LONG) + value = va_arg(args, unsigned long long); + else + value = va_arg(args, unsigned int); + fmtint(buffer, &currlen, maxlen, value, 8, min, max, flags); break; - default: /* hmm? */ - break; /* some picky compilers need this */ + case 'u': + flags |= DP_F_UNSIGNED; + if (cflags == DP_C_SHORT) + value = va_arg(args, unsigned int); + else if (cflags == DP_C_LONG) + value = va_arg(args, unsigned long int); + else if (cflags == DP_C_LONG_LONG) + value = va_arg(args, unsigned long long); + else + value = va_arg(args, unsigned int); + fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags); + break; + case 'X': + flags |= DP_F_UP; + case 'x': + flags |= DP_F_UNSIGNED; + if (cflags == DP_C_SHORT) + value = va_arg(args, unsigned int); + else if (cflags == DP_C_LONG) + value = va_arg(args, unsigned long int); + else if (cflags == DP_C_LONG_LONG) + value = va_arg(args, unsigned long long); + else + value = va_arg(args, unsigned int); + fmtint(buffer, &currlen, maxlen, value, 16, min, max, flags); + break; + case 'f': + if (cflags == DP_C_LDOUBLE) + fvalue = va_arg(args, long double); + else + fvalue = va_arg(args, double); + /* um, floating point? */ + fmtfp(buffer, &currlen, maxlen, fvalue, min, max, flags); + break; + case 'E': + flags |= DP_F_UP; + case 'e': + if (cflags == DP_C_LDOUBLE) + fvalue = va_arg(args, long double); + else + fvalue = va_arg(args, double); + break; + case 'G': + flags |= DP_F_UP; + case 'g': + if (cflags == DP_C_LDOUBLE) + fvalue = va_arg(args, long double); + else + fvalue = va_arg(args, double); + break; + case 'c': + dopr_outch(buffer, &currlen, maxlen, va_arg(args, int)); + break; + case 's': + strvalue = va_arg(args, char *); + if (max < 0) + max = maxlen; /* ie, no max */ + fmtstr(buffer, &currlen, maxlen, strvalue, flags, min, max); + break; + case 'p': + strvalue = va_arg(args, void *); + fmtint(buffer, &currlen, maxlen, (long) strvalue, 16, min, max, flags); + break; + case 'n': + if (cflags == DP_C_SHORT) { + short int *num; + num = va_arg(args, short int *); + *num = currlen; + } else if (cflags == DP_C_LONG) { + long int *num; + num = va_arg(args, long int *); + *num = currlen; + } else if (cflags == DP_C_LONG_LONG) { + long long *num; + num = va_arg(args, long long *); + *num = currlen; + } else { + int *num; + num = va_arg(args, int *); + *num = currlen; + } + break; + case '%': + dopr_outch(buffer, &currlen, maxlen, ch); + break; + case 'w': /* not supported yet, treat as next char */ + ch = *format++; + break; + default: /* Unknown, skip */ + break; + } + ch = *format++; + state = DP_S_DEFAULT; + flags = cflags = min = 0; + max = -1; + break; + case DP_S_DONE: + break; + default: /* hmm? */ + break; /* some picky compilers need this */ } } if (currlen < maxlen - 1) @@ -367,10 +362,9 @@ dopr(char *buffer, size_t maxlen, const char *format, va_list args) static void fmtstr(char *buffer, size_t *currlen, size_t maxlen, - char *value, int flags, int min, int max) + char *value, int flags, int min, int max) { - int padlen, strln; /* amount to pad */ - int cnt = 0; + int cnt = 0, padlen, strln; /* amount to pad */ if (value == 0) value = ""; @@ -402,15 +396,13 @@ fmtstr(char *buffer, size_t *currlen, size_t maxlen, static void fmtint(char *buffer, size_t *currlen, size_t maxlen, - long value, int base, int min, int max, int flags) + long value, int base, int min, int max, int flags) { unsigned long uvalue; char convert[20]; - int signvalue = 0; - int place = 0; + int signvalue = 0, place = 0, caps = 0; int spadlen = 0; /* amount to space pad */ int zpadlen = 0; /* amount to zero pad */ - int caps = 0; if (max < 0) max = 0; @@ -429,11 +421,10 @@ fmtint(char *buffer, size_t *currlen, size_t maxlen, if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */ - do { convert[place++] = - (caps? "0123456789ABCDEF":"0123456789abcdef") - [uvalue % (unsigned)base]; + (caps ? "0123456789ABCDEF" : "0123456789abcdef") + [uvalue % (unsigned)base]; uvalue = (uvalue / (unsigned)base ); } while (uvalue && (place < 20)); if (place == 20) @@ -453,7 +444,6 @@ fmtint(char *buffer, size_t *currlen, size_t maxlen, if (flags & DP_F_MINUS) spadlen = -spadlen; /* Left Justifty */ - /* Spaces */ while (spadlen > 0) { dopr_outch(buffer, currlen, maxlen, ' '); @@ -512,16 +502,11 @@ static void fmtfp(char *buffer, size_t *currlen, size_t maxlen, long double fvalue, int min, int max, int flags) { - char iconvert[20]; - char fconvert[20]; - int signvalue = 0; - int iplace = 0; - int fplace = 0; + char iconvert[20], fconvert[20]; + int signvalue = 0, iplace = 0, fplace = 0; int padlen = 0; /* amount to pad */ - int zpadlen = 0; - int caps = 0; - long intpart; - long fracpart; + int zpadlen = 0, caps = 0; + long intpart, fracpart; long double ufvalue; /* @@ -562,7 +547,8 @@ fmtfp(char *buffer, size_t *currlen, size_t maxlen, long double fvalue, /* Convert integer part */ do { iconvert[iplace++] = - (caps? "0123456789ABCDEF":"0123456789abcdef")[intpart % 10]; + (caps ? "0123456789ABCDEF" : "0123456789abcdef") + [intpart % 10]; intpart = (intpart / 10); } while(intpart && (iplace < 20)); if (iplace == 20) @@ -572,7 +558,8 @@ fmtfp(char *buffer, size_t *currlen, size_t maxlen, long double fvalue, /* Convert fractional part */ do { fconvert[fplace++] = - (caps? "0123456789ABCDEF":"0123456789abcdef")[fracpart % 10]; + (caps ? "0123456789ABCDEF" : "0123456789abcdef") + [fracpart % 10]; fracpart = (fracpart / 10); } while(fracpart && (fplace < 20)); if (fplace == 20) @@ -611,8 +598,8 @@ fmtfp(char *buffer, size_t *currlen, size_t maxlen, long double fvalue, dopr_outch(buffer, currlen, maxlen, iconvert[--iplace]); /* - * Decimal point. This should probably use locale to find the correct - * char to print out. + * Decimal point. This should probably use locale to find the + * correct char to print out. */ dopr_outch(buffer, currlen, maxlen, '.'); @@ -662,90 +649,4 @@ snprintf(char *str,size_t count,const char *fmt,...) return(strlen(str)); } -#ifdef TEST_SNPRINTF -int -main(void) -{ -#define LONG_STRING 1024 - char buf1[LONG_STRING]; - char buf2[LONG_STRING]; - char *fp_fmt[] = { - "%-1.5f", - "%1.5f", - "%123.9f", - "%10.5f", - "% 10.5f", - "%+22.9f", - "%+4.9f", - "%01.3f", - "%4f", - "%3.1f", - "%3.2f", - NULL - }; - double fp_nums[] = { - -1.5, - 134.21, - 91340.2, - 341.1234, - 0203.9, - 0.96, - 0.996, - 0.9996, - 1.996, - 4.136, - 0 - }; - char *int_fmt[] = { - "%-1.5d", - "%1.5d", - "%123.9d", - "%5.5d", - "%10.5d", - "% 10.5d", - "%+22.33d", - "%01.3d", - "%4d", - "%lld", - "%qd", - NULL - }; - long long int_nums[] = { -1, 134, 91340, 341, 0203, 0, 9999999 }; - int x, y; - int fail = 0; - int num = 0; - - printf("Testing snprintf format codes against system sprintf...\n"); - - for (x = 0; fp_fmt[x] != NULL ; x++) { - for (y = 0; fp_nums[y] != 0 ; y++) { - snprintf(buf1, sizeof (buf1), fp_fmt[x], fp_nums[y]); - sprintf (buf2, fp_fmt[x], fp_nums[y]); - if (strcmp (buf1, buf2)) { - printf("snprintf doesn't match Format: %s\n\t" - "snprintf = %s\n\tsprintf = %s\n", - fp_fmt[x], buf1, buf2); - fail++; - } - num++; - } - } - for (x = 0; int_fmt[x] != NULL ; x++) { - for (y = 0; int_nums[y] != 0 ; y++) { - snprintf(buf1, sizeof (buf1), int_fmt[x], int_nums[y]); - sprintf(buf2, int_fmt[x], int_nums[y]); - if (strcmp (buf1, buf2)) { - printf("snprintf doesn't match Format: %s\n\t" - "snprintf = %s\n\tsprintf = %s\n", - int_fmt[x], buf1, buf2); - fail++; - } - num++; - } - } - printf("%d tests failed out of %d.\n", fail, num); - return(0); -} -#endif /* SNPRINTF_TEST */ - #endif /* !HAVE_SNPRINTF */ diff --git a/openbsd-compat/bsd-snprintf.h b/openbsd-compat/bsd-snprintf.h index 002b764e3..95e4d136c 100644 --- a/openbsd-compat/bsd-snprintf.h +++ b/openbsd-compat/bsd-snprintf.h @@ -1,4 +1,4 @@ -/* $Id: bsd-snprintf.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */ +/* $Id: bsd-snprintf.h,v 1.3 2003/05/18 14:13:39 djm Exp $ */ #ifndef _BSD_SNPRINTF_H #define _BSD_SNPRINTF_H @@ -8,11 +8,11 @@ #include /* For size_t */ #ifndef HAVE_SNPRINTF -int snprintf(char *str, size_t count, const char *fmt, ...); +int snprintf(char *, size_t, const char *, ...); #endif /* !HAVE_SNPRINTF */ #ifndef HAVE_VSNPRINTF -int vsnprintf(char *str, size_t count, const char *fmt, va_list args); +int vsnprintf(char *, size_t, const char *, va_list); #endif /* !HAVE_SNPRINTF */ diff --git a/openbsd-compat/bsd-waitpid.c b/openbsd-compat/bsd-waitpid.c index 47b4446dc..d60081e58 100644 --- a/openbsd-compat/bsd-waitpid.c +++ b/openbsd-compat/bsd-waitpid.c @@ -1,3 +1,5 @@ +/* XXX - no author */ + /* * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -22,7 +24,7 @@ #include "includes.h" -RCSID("$Id: bsd-waitpid.c,v 1.3 2001/03/26 05:35:34 mouring Exp $"); +RCSID("$Id: bsd-waitpid.c,v 1.4 2003/05/18 14:13:39 djm Exp $"); #ifndef HAVE_WAITPID #include @@ -38,15 +40,16 @@ waitpid(int pid, int *stat_loc, int options) if (pid <= 0) { if (pid != -1) { errno = EINVAL; - return -1; + return (-1); } - pid = 0; /* wait4() wants pid=0 for indiscriminate wait. */ + /* wait4() wants pid=0 for indiscriminate wait. */ + pid = 0; } wait_pid = wait4(pid, &statusp, options, NULL); if (stat_loc) *stat_loc = (int) statusp.w_status; - return wait_pid; + return (wait_pid); } #endif /* !HAVE_WAITPID */ diff --git a/openbsd-compat/bsd-waitpid.h b/openbsd-compat/bsd-waitpid.h index e24edd791..6d48deb29 100644 --- a/openbsd-compat/bsd-waitpid.h +++ b/openbsd-compat/bsd-waitpid.h @@ -21,7 +21,7 @@ * */ -/* $Id: bsd-waitpid.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */ +/* $Id: bsd-waitpid.h,v 1.3 2003/05/18 14:13:39 djm Exp $ */ #ifndef _BSD_WAITPID_H #define _BSD_WAITPID_H @@ -43,7 +43,7 @@ #define WCOREDUMP(w) ((_W_INT(w)) & WCOREFLAG) /* Prototype */ -pid_t waitpid(int pid, int *stat_loc, int options); +pid_t waitpid(int, int *, int); #endif /* !HAVE_WAITPID */ #endif /* _BSD_WAITPID_H */ diff --git a/openbsd-compat/fake-gai-errnos.h b/openbsd-compat/fake-gai-errnos.h index 5edc31b59..8fca7db0c 100644 --- a/openbsd-compat/fake-gai-errnos.h +++ b/openbsd-compat/fake-gai-errnos.h @@ -5,10 +5,15 @@ * See getaddrinfo.c and getnameinfo.c. */ -/* $Id: fake-gai-errnos.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */ +#ifndef _FAKE_GAI_ERRNOS_H +#define _FAKE_GAI_ERRNOS_H + +/* $Id: fake-gai-errnos.h,v 1.3 2003/05/18 14:13:39 djm Exp $ */ /* for old netdb.h */ #ifndef EAI_NODATA -#define EAI_NODATA 1 -#define EAI_MEMORY 2 +# define EAI_NODATA 1 +# define EAI_MEMORY 2 #endif + +#endif /* !_FAKE_GAI_ERRNOS_H */ diff --git a/openbsd-compat/fake-getaddrinfo.c b/openbsd-compat/fake-getaddrinfo.c index 34e1fce78..76b8a6274 100644 --- a/openbsd-compat/fake-getaddrinfo.c +++ b/openbsd-compat/fake-getaddrinfo.c @@ -10,47 +10,48 @@ */ #include "includes.h" +#include "xmalloc.h" #include "ssh.h" -RCSID("$Id: fake-getaddrinfo.c,v 1.6 2003/05/14 11:48:51 dtucker Exp $"); +RCSID("$Id: fake-getaddrinfo.c,v 1.7 2003/05/18 14:13:39 djm Exp $"); #ifndef HAVE_GAI_STRERROR -char *gai_strerror(int ecode) +char * +gai_strerror(int err) { - switch (ecode) { - case EAI_NODATA: - return "no address associated with hostname."; - case EAI_MEMORY: - return "memory allocation failure."; - default: - return "unknown error."; + switch (err) { + case EAI_NODATA: + return ("no address associated with name"); + case EAI_MEMORY: + return ("memory allocation failure."); + default: + return ("unknown/invalid error."); } } #endif /* !HAVE_GAI_STRERROR */ #ifndef HAVE_FREEADDRINFO -void freeaddrinfo(struct addrinfo *ai) +void +freeaddrinfo(struct addrinfo *ai) { struct addrinfo *next; - do { - next = ai->ai_next; + for(;ai != NULL; next = ai->ai_next) { free(ai); - } while (NULL != (ai = next)); + ai = next; + } } #endif /* !HAVE_FREEADDRINFO */ #ifndef HAVE_GETADDRINFO -static struct addrinfo *malloc_ai(int port, u_long addr, - const struct addrinfo *hints) +static struct +addrinfo *malloc_ai(int port, u_long addr, const struct addrinfo *hints) { struct addrinfo *ai; - ai = malloc(sizeof(struct addrinfo) + sizeof(struct sockaddr_in)); - if (ai == NULL) - return(NULL); + ai = xmalloc(sizeof(*ai) + sizeof(struct sockaddr_in)); - memset(ai, 0, sizeof(struct addrinfo) + sizeof(struct sockaddr_in)); + memset(ai, '\0', sizeof(*ai) + sizeof(struct sockaddr_in)); ai->ai_addr = (struct sockaddr *)(ai + 1); /* XXX -- ssh doesn't use sa_len */ @@ -69,13 +70,13 @@ static struct addrinfo *malloc_ai(int port, u_long addr, if (hints->ai_protocol) ai->ai_protocol = hints->ai_protocol; - return(ai); + return (ai); } -int getaddrinfo(const char *hostname, const char *servname, - const struct addrinfo *hints, struct addrinfo **res) +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; @@ -100,37 +101,29 @@ int getaddrinfo(const char *hostname, const char *servname, addr = htonl(0x00000000); if (hostname && inet_aton(hostname, &in) != 0) addr = in.s_addr; - if (NULL != (*res = malloc_ai(port, addr, hints))) - return 0; - else - return EAI_MEMORY; + *res = malloc_ai(port, addr, hints); + return (0); } if (!hostname) { - if (NULL != (*res = malloc_ai(port, htonl(0x7f000001), hints))) - return 0; - else - return EAI_MEMORY; + *res = malloc_ai(port, htonl(0x7f000001), hints); + return (0); } if (inet_aton(hostname, &in)) { - if (NULL != (*res = malloc_ai(port, in.s_addr, hints))) - return 0; - else - return EAI_MEMORY; + *res = malloc_ai(port, in.s_addr, hints); + return (0); } hp = gethostbyname(hostname); if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) { + struct addrinfo *cur, *prev; + + cur = prev = NULL; for (i = 0; hp->h_addr_list[i]; i++) { - cur = malloc_ai(port, - ((struct in_addr *)hp->h_addr_list[i])->s_addr, hints); - if (cur == NULL) { - if (*res) - freeaddrinfo(*res); - return EAI_MEMORY; - } - + struct in_addr *in = (struct in_addr *)hp->h_addr_list[i]; + + cur = malloc_ai(port, in->s_addr, hints); if (prev) prev->ai_next = cur; else @@ -138,9 +131,9 @@ int getaddrinfo(const char *hostname, const char *servname, prev = cur; } - return 0; + return (0); } - return EAI_NODATA; + return (EAI_NODATA); } #endif /* !HAVE_GETADDRINFO */ diff --git a/openbsd-compat/fake-getnameinfo.c b/openbsd-compat/fake-getnameinfo.c index e255ed333..f3b0913de 100644 --- a/openbsd-compat/fake-getnameinfo.c +++ b/openbsd-compat/fake-getnameinfo.c @@ -12,7 +12,7 @@ #include "includes.h" #include "ssh.h" -RCSID("$Id: fake-getnameinfo.c,v 1.2 2001/02/09 01:55:36 djm Exp $"); +RCSID("$Id: fake-getnameinfo.c,v 1.3 2003/05/18 14:13:39 djm Exp $"); #ifndef HAVE_GETNAMEINFO int getnameinfo(const struct sockaddr *sa, size_t salen, char *host, @@ -22,34 +22,31 @@ int getnameinfo(const struct sockaddr *sa, size_t salen, char *host, struct hostent *hp; char tmpserv[16]; - if (serv) { + if (serv != NULL) { snprintf(tmpserv, sizeof(tmpserv), "%d", ntohs(sin->sin_port)); - if (strlen(tmpserv) >= servlen) - return EAI_MEMORY; - else - strcpy(serv, tmpserv); + if (strlcpy(serv, tmpserv, servlen) >= servlen) + return (EAI_MEMORY); } - if (host) { + if (host != NULL) { if (flags & NI_NUMERICHOST) { - if (strlen(inet_ntoa(sin->sin_addr)) >= hostlen) - return EAI_MEMORY; - - strcpy(host, inet_ntoa(sin->sin_addr)); - return 0; + if (strlcpy(host, inet_ntoa(sin->sin_addr), + hostlen) >= hostlen) + return (EAI_MEMORY); + else + return (0); } else { hp = gethostbyaddr((char *)&sin->sin_addr, - sizeof(struct in_addr), AF_INET); + sizeof(struct in_addr), AF_INET); if (hp == NULL) - return EAI_NODATA; + return (EAI_NODATA); - if (strlen(hp->h_name) >= hostlen) - return EAI_MEMORY; - - strcpy(host, hp->h_name); - return 0; + if (strlcpy(host, hp->h_name, hostlen) >= hostlen) + return (EAI_MEMORY); + else + return (0); } } - return 0; + return (0); } #endif /* !HAVE_GETNAMEINFO */ diff --git a/openbsd-compat/fake-getnameinfo.h b/openbsd-compat/fake-getnameinfo.h index c9b7908aa..7aaabc7f6 100644 --- a/openbsd-compat/fake-getnameinfo.h +++ b/openbsd-compat/fake-getnameinfo.h @@ -1,4 +1,4 @@ -/* $Id: fake-getnameinfo.h,v 1.2 2001/02/09 01:55:36 djm Exp $ */ +/* $Id: fake-getnameinfo.h,v 1.3 2003/05/18 14:13:39 djm Exp $ */ #ifndef _FAKE_GETNAMEINFO_H #define _FAKE_GETNAMEINFO_H @@ -6,8 +6,8 @@ #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); +int getnameinfo(const struct sockaddr *, size_t, char *, size_t, + char *, size_t, int); #endif /* !HAVE_GETNAMEINFO */ #ifndef NI_MAXSERV diff --git a/openbsd-compat/port-aix.c b/openbsd-compat/port-aix.c index cddc0907f..7a42810e9 100644 --- a/openbsd-compat/port-aix.c +++ b/openbsd-compat/port-aix.c @@ -46,14 +46,18 @@ void aix_usrinfo(struct passwd *pw) { u_int i; + size_t len; char *cp; - cp = xmalloc(16 + 2 * strlen(pw->pw_name)); - i = sprintf(cp, "LOGNAME=%s%cNAME=%s%c", pw->pw_name, 0, - pw->pw_name, 0); + len = sizeof("LOGNAME= NAME= ") + (2 * strlen(pw->pw_name)); + cp = xmalloc(len); + + i = snprintf(cp, "LOGNAME=%s%cNAME=%s%c", pw->pw_name, '\0', + pw->pw_name, '\0', len); if (usrinfo(SETUINFO, cp, i) == -1) fatal("Couldn't set usrinfo: %s", strerror(errno)); debug3("AIX/UsrInfo: set len %d", i); + xfree(cp); } @@ -64,8 +68,9 @@ aix_usrinfo(struct passwd *pw) void record_failed_login(const char *user, const char *ttyname) { - loginfailed(user, - get_canonical_hostname(options.verify_reverse_mapping), ttyname); + char *hostname = get_canonical_hostname(options.verify_reverse_mapping); + + loginfailed(user, hostname, ttyname); } # endif /* CUSTOM_FAILED_LOGIN */ #endif /* _AIX */ diff --git a/openbsd-compat/port-irix.c b/openbsd-compat/port-irix.c index a63ec429a..1b212980d 100644 --- a/openbsd-compat/port-irix.c +++ b/openbsd-compat/port-irix.c @@ -1,15 +1,19 @@ +/* XXX - BSD license here */ + #include "includes.h" -#if defined(WITH_IRIX_PROJECT) || defined(WITH_IRIX_JOBS) || defined(WITH_IRIX_ARRAY) +#if defined(WITH_IRIX_PROJECT) || \ + defined(WITH_IRIX_JOBS) || \ + defined(WITH_IRIX_ARRAY) #ifdef WITH_IRIX_PROJECT -#include +# include #endif /* WITH_IRIX_PROJECT */ #ifdef WITH_IRIX_JOBS -#include +# include #endif #ifdef WITH_IRIX_AUDIT -#include +# include #endif /* WITH_IRIX_AUDIT */ void @@ -17,14 +21,12 @@ irix_setusercontext(struct passwd *pw) { #ifdef WITH_IRIX_PROJECT prid_t projid; -#endif /* WITH_IRIX_PROJECT */ +#endif #ifdef WITH_IRIX_JOBS jid_t jid = 0; -#else -# ifdef WITH_IRIX_ARRAY +#elif defined(WITH_IRIX_ARRAY) int jid = 0; -# endif /* WITH_IRIX_ARRAY */ -#endif /* WITH_IRIX_JOBS */ +#endif #ifdef WITH_IRIX_JOBS jid = jlimit_startjob(pw->pw_name, pw->pw_uid, "interactive"); diff --git a/openbsd-compat/port-irix.h b/openbsd-compat/port-irix.h index 2dd3c2e25..fd9f09e6c 100644 --- a/openbsd-compat/port-irix.h +++ b/openbsd-compat/port-irix.h @@ -1,5 +1,14 @@ -#if defined(WITH_IRIX_PROJECT) || defined(WITH_IRIX_JOBS) || defined(WITH_IRIX_ARRAY) +/* XXX - BSD license */ + +#ifndef _PORT_IRIX_H +#define _PORT_IRIX_H + +#if defined(WITH_IRIX_PROJECT) || \ + defined(WITH_IRIX_JOBS) || \ + defined(WITH_IRIX_ARRAY) void irix_setusercontext(struct passwd *pw); #endif /* defined(WITH_IRIX_PROJECT) || defined(WITH_IRIX_JOBS) || defined(WITH_IRIX_ARRAY) */ + +#endif /* ! _PORT_IRIX_H */ diff --git a/openbsd-compat/vis.c b/openbsd-compat/vis.c index 0d15886f0..92b2ac498 100644 --- a/openbsd-compat/vis.c +++ b/openbsd-compat/vis.c @@ -38,6 +38,7 @@ static char rcsid[] = "$OpenBSD: vis.c,v 1.11 2003/05/14 05:16:43 pjanzen Exp $" #endif /* LIBC_SCCS and not lint */ #include +#include #include "vis.h" -- cgit v1.2.3 From 515d0f9a1eeedcbd03bb78cf09a17d99e597b5a3 Mon Sep 17 00:00:00 2001 From: Ben Lindstrom Date: Fri, 29 Aug 2003 16:59:52 +0000 Subject: - (bal) openbsd-compat/ clean up. Considate headers, add in $Id$ on our files, and added missing license to header. --- ChangeLog | 6 +- auth-passwd.c | 1 - monitor_mm.c | 1 - openbsd-compat/base64.h | 46 ++++++++++++- openbsd-compat/basename.h | 12 ---- openbsd-compat/bindresvport.h | 12 ---- openbsd-compat/bsd-arc4random.h | 37 ---------- openbsd-compat/bsd-cray.h | 9 ++- openbsd-compat/bsd-getpeereid.h | 38 ----------- openbsd-compat/bsd-misc.h | 6 +- openbsd-compat/bsd-nextstep.h | 4 +- openbsd-compat/bsd-snprintf.h | 19 ------ openbsd-compat/bsd-waitpid.h | 4 +- openbsd-compat/daemon.h | 11 --- openbsd-compat/dirname.h | 5 -- openbsd-compat/fake-rfc2553.h | 4 +- openbsd-compat/getcwd.h | 12 ---- openbsd-compat/getgrouplist.h | 16 ----- openbsd-compat/getopt.h | 14 ---- openbsd-compat/getrrsetbyname.h | 2 +- openbsd-compat/inet_aton.h | 12 ---- openbsd-compat/inet_ntoa.h | 12 ---- openbsd-compat/inet_ntop.h | 13 ---- openbsd-compat/mktemp.h | 13 ---- openbsd-compat/openbsd-compat.h | 147 +++++++++++++++++++++++++++++++++------- openbsd-compat/port-aix.h | 3 +- openbsd-compat/port-irix.h | 2 + openbsd-compat/realpath.h | 13 ---- openbsd-compat/rresvport.h | 12 ---- openbsd-compat/setenv.h | 14 ---- openbsd-compat/setproctitle.h | 13 ---- openbsd-compat/strlcat.h | 12 ---- openbsd-compat/strlcpy.h | 12 ---- openbsd-compat/strmode.h | 7 -- openbsd-compat/strsep.h | 12 ---- openbsd-compat/vis.c | 2 +- openbsd-compat/vis.h | 2 +- openbsd-compat/xcrypt.h | 28 -------- openbsd-compat/xmmap.h | 27 -------- 39 files changed, 190 insertions(+), 425 deletions(-) delete mode 100644 openbsd-compat/basename.h delete mode 100644 openbsd-compat/bindresvport.h delete mode 100644 openbsd-compat/bsd-arc4random.h delete mode 100644 openbsd-compat/bsd-getpeereid.h delete mode 100644 openbsd-compat/bsd-snprintf.h delete mode 100644 openbsd-compat/daemon.h delete mode 100644 openbsd-compat/dirname.h delete mode 100644 openbsd-compat/getcwd.h delete mode 100644 openbsd-compat/getgrouplist.h delete mode 100644 openbsd-compat/getopt.h delete mode 100644 openbsd-compat/inet_aton.h delete mode 100644 openbsd-compat/inet_ntoa.h delete mode 100644 openbsd-compat/inet_ntop.h delete mode 100644 openbsd-compat/mktemp.h delete mode 100644 openbsd-compat/realpath.h delete mode 100644 openbsd-compat/rresvport.h delete mode 100644 openbsd-compat/setenv.h delete mode 100644 openbsd-compat/setproctitle.h delete mode 100644 openbsd-compat/strlcat.h delete mode 100644 openbsd-compat/strlcpy.h delete mode 100644 openbsd-compat/strmode.h delete mode 100644 openbsd-compat/strsep.h delete mode 100644 openbsd-compat/xcrypt.h delete mode 100644 openbsd-compat/xmmap.h (limited to 'openbsd-compat/bsd-cray.h') diff --git a/ChangeLog b/ChangeLog index fb33982c0..d916025e3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +20030829 + - (bal) openbsd-compat/ clean up. Considate headers, add in $Id: ChangeLog,v 1.2918 2003/08/29 16:59:52 mouring Exp $ on our + files, and added missing license to header. + 20030826 - (djm) Bug #629: Mark ssh_config option "pamauthenticationviakbdint" as deprecated. Remove mention from README.privsep. Patch from @@ -908,4 +912,4 @@ - Fix sshd BindAddress and -b options for systems using fake-getaddrinfo. Report from murple@murple.net, diagnosis from dtucker@zip.com.au -$Id: ChangeLog,v 1.2917 2003/08/26 04:22:12 dtucker Exp $ +$Id: ChangeLog,v 1.2918 2003/08/29 16:59:52 mouring Exp $ diff --git a/auth-passwd.c b/auth-passwd.c index 780e92344..a5d23b6bf 100644 --- a/auth-passwd.c +++ b/auth-passwd.c @@ -42,7 +42,6 @@ RCSID("$OpenBSD: auth-passwd.c,v 1.28 2003/07/22 13:35:22 markus Exp $"); #include "log.h" #include "servconf.h" #include "auth.h" -#include "openbsd-compat/xcrypt.h" #ifdef WITH_AIXAUTHENTICATE # include "buffer.h" # include "canohost.h" diff --git a/monitor_mm.c b/monitor_mm.c index b4a6e40c9..e57c87cc2 100644 --- a/monitor_mm.c +++ b/monitor_mm.c @@ -30,7 +30,6 @@ RCSID("$OpenBSD: monitor_mm.c,v 1.8 2002/08/02 14:43:15 millert Exp $"); #include #endif -#include "openbsd-compat/xmmap.h" #include "ssh.h" #include "xmalloc.h" #include "log.h" diff --git a/openbsd-compat/base64.h b/openbsd-compat/base64.h index a25003016..732c6b3f8 100644 --- a/openbsd-compat/base64.h +++ b/openbsd-compat/base64.h @@ -1,9 +1,51 @@ -/* $Id: base64.h,v 1.5 2003/05/15 03:57:51 djm Exp $ */ +/* $Id: base64.h,v 1.6 2003/08/29 16:59:52 mouring Exp $ */ + +/* + * Copyright (c) 1996 by Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +/* + * Portions Copyright (c) 1995 by International Business Machines, Inc. + * + * International Business Machines, Inc. (hereinafter called IBM) grants + * permission under its copyrights to use, copy, modify, and distribute this + * Software with or without fee, provided that the above copyright notice and + * all paragraphs of this notice appear in all copies, and that the name of IBM + * not be used in connection with the marketing of any product incorporating + * the Software or modifications thereof, without specific, written prior + * permission. + * + * To the extent it has a right to do so, IBM grants an immunity from suit + * under its patents, if any, for the use, sale or manufacture of products to + * the extent that such products are used for performing Domain Name System + * dynamic updates in TCP/IP networks by means of the Software. No immunity is + * granted for any product per se or for any other function of any product. + * + * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, + * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN + * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES. + */ #ifndef _BSD_BASE64_H #define _BSD_BASE64_H -#include "config.h" +#include "includes.h" #ifndef HAVE___B64_NTOP # ifndef HAVE_B64_NTOP diff --git a/openbsd-compat/basename.h b/openbsd-compat/basename.h deleted file mode 100644 index a8bd6c17c..000000000 --- a/openbsd-compat/basename.h +++ /dev/null @@ -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 */ diff --git a/openbsd-compat/bindresvport.h b/openbsd-compat/bindresvport.h deleted file mode 100644 index b42f46983..000000000 --- a/openbsd-compat/bindresvport.h +++ /dev/null @@ -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 */ diff --git a/openbsd-compat/bsd-arc4random.h b/openbsd-compat/bsd-arc4random.h deleted file mode 100644 index 7af757b2d..000000000 --- a/openbsd-compat/bsd-arc4random.h +++ /dev/null @@ -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 */ diff --git a/openbsd-compat/bsd-cray.h b/openbsd-compat/bsd-cray.h index 433144f6f..a121ea152 100644 --- a/openbsd-compat/bsd-cray.h +++ b/openbsd-compat/bsd-cray.h @@ -1,8 +1,6 @@ -/* - * $Id: bsd-cray.h,v 1.9 2003/05/18 14:13:39 djm Exp $ - * - * bsd-cray.h - * +/* $Id: bsd-cray.h,v 1.10 2003/08/29 16:59:52 mouring Exp $ */ + +/* * Copyright (c) 2002, Cray Inc. (Wendy Palm ) * Significant portions provided by * Wayne Schroeder, SDSC @@ -34,6 +32,7 @@ * on UNICOS systems. * */ + #ifndef _BSD_CRAY_H #define _BSD_CRAY_H diff --git a/openbsd-compat/bsd-getpeereid.h b/openbsd-compat/bsd-getpeereid.h deleted file mode 100644 index 771e9cbf9..000000000 --- a/openbsd-compat/bsd-getpeereid.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2002-2003 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-getpeereid.h,v 1.2 2003/05/18 14:13:39 djm Exp $ */ - -#ifndef _BSD_GETPEEREID_H -#define _BSD_GETPEEREID_H - -#include "config.h" - -#include /* For uid_t, gid_t */ - -#ifndef HAVE_GETPEEREID -int getpeereid(int , uid_t *, gid_t *); -#endif /* HAVE_GETPEEREID */ - -#endif /* _BSD_GETPEEREID_H */ diff --git a/openbsd-compat/bsd-misc.h b/openbsd-compat/bsd-misc.h index 0d6076ab0..6b70473f3 100644 --- a/openbsd-compat/bsd-misc.h +++ b/openbsd-compat/bsd-misc.h @@ -1,3 +1,5 @@ +/* $Id: bsd-misc.h,v 1.13 2003/08/29 16:59:52 mouring Exp $ */ + /* * Copyright (c) 1999-2003 Damien Miller. All rights reserved. * @@ -22,12 +24,10 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* $Id: bsd-misc.h,v 1.12 2003/08/25 01:16:22 mouring Exp $ */ - #ifndef _BSD_MISC_H #define _BSD_MISC_H -#include "config.h" +#include "includes.h" char *ssh_get_progname(char *); diff --git a/openbsd-compat/bsd-nextstep.h b/openbsd-compat/bsd-nextstep.h index 057462710..ca5b4b54a 100644 --- a/openbsd-compat/bsd-nextstep.h +++ b/openbsd-compat/bsd-nextstep.h @@ -1,3 +1,5 @@ +/* $Id: bsd-nextstep.h,v 1.9 2003/08/29 16:59:52 mouring Exp $ */ + /* * Copyright (c) 2000,2001 Ben Lindstrom. All rights reserved. * @@ -23,8 +25,6 @@ * */ -/* $Id: bsd-nextstep.h,v 1.8 2003/06/01 03:23:57 mouring Exp $ */ - #ifndef _NEXT_POSIX_H #define _NEXT_POSIX_H diff --git a/openbsd-compat/bsd-snprintf.h b/openbsd-compat/bsd-snprintf.h deleted file mode 100644 index 95e4d136c..000000000 --- a/openbsd-compat/bsd-snprintf.h +++ /dev/null @@ -1,19 +0,0 @@ -/* $Id: bsd-snprintf.h,v 1.3 2003/05/18 14:13:39 djm Exp $ */ - -#ifndef _BSD_SNPRINTF_H -#define _BSD_SNPRINTF_H - -#include "config.h" - -#include /* For size_t */ - -#ifndef HAVE_SNPRINTF -int snprintf(char *, size_t, const char *, ...); -#endif /* !HAVE_SNPRINTF */ - -#ifndef HAVE_VSNPRINTF -int vsnprintf(char *, size_t, const char *, va_list); -#endif /* !HAVE_SNPRINTF */ - - -#endif /* _BSD_SNPRINTF_H */ diff --git a/openbsd-compat/bsd-waitpid.h b/openbsd-compat/bsd-waitpid.h index 00bfb9144..2d853db61 100644 --- a/openbsd-compat/bsd-waitpid.h +++ b/openbsd-compat/bsd-waitpid.h @@ -1,3 +1,5 @@ +/* $Id: bsd-waitpid.h,v 1.5 2003/08/29 16:59:52 mouring Exp $ */ + /* * Copyright (c) 2000 Ben Lindstrom. All rights reserved. * @@ -23,8 +25,6 @@ * */ -/* $Id: bsd-waitpid.h,v 1.4 2003/06/01 03:23:57 mouring Exp $ */ - #ifndef _BSD_WAITPID_H #define _BSD_WAITPID_H diff --git a/openbsd-compat/daemon.h b/openbsd-compat/daemon.h deleted file mode 100644 index 95a077359..000000000 --- a/openbsd-compat/daemon.h +++ /dev/null @@ -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 */ diff --git a/openbsd-compat/dirname.h b/openbsd-compat/dirname.h deleted file mode 100644 index 1d61dd06c..000000000 --- a/openbsd-compat/dirname.h +++ /dev/null @@ -1,5 +0,0 @@ -#ifndef HAVE_DIRNAME - -char *dirname(const char *path); - -#endif diff --git a/openbsd-compat/fake-rfc2553.h b/openbsd-compat/fake-rfc2553.h index 1a6c31e9c..b70b928f8 100644 --- a/openbsd-compat/fake-rfc2553.h +++ b/openbsd-compat/fake-rfc2553.h @@ -1,3 +1,5 @@ +/* $Id: fake-rfc2553.h,v 1.6 2003/08/29 16:59:52 mouring Exp $ */ + /* * Copyright (C) 2000-2003 Damien Miller. All rights reserved. * Copyright (C) 1999 WIDE Project. All rights reserved. @@ -35,8 +37,6 @@ * that ai_family is AF_INET. Don't use it for another purpose. */ -/* $Id: fake-rfc2553.h,v 1.5 2003/08/08 02:15:12 dtucker Exp $ */ - #ifndef _FAKE_RFC2553_H #define _FAKE_RFC2553_H diff --git a/openbsd-compat/getcwd.h b/openbsd-compat/getcwd.h deleted file mode 100644 index 1137b3ed5..000000000 --- a/openbsd-compat/getcwd.h +++ /dev/null @@ -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 */ diff --git a/openbsd-compat/getgrouplist.h b/openbsd-compat/getgrouplist.h deleted file mode 100644 index 27a9703f2..000000000 --- a/openbsd-compat/getgrouplist.h +++ /dev/null @@ -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 - -int getgrouplist(const char *, gid_t, gid_t *, int *); - -#endif - -#endif diff --git a/openbsd-compat/getopt.h b/openbsd-compat/getopt.h deleted file mode 100644 index 9abdae8e9..000000000 --- a/openbsd-compat/getopt.h +++ /dev/null @@ -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 */ diff --git a/openbsd-compat/getrrsetbyname.h b/openbsd-compat/getrrsetbyname.h index 9edaf0ae2..6466a54d6 100644 --- a/openbsd-compat/getrrsetbyname.h +++ b/openbsd-compat/getrrsetbyname.h @@ -46,7 +46,7 @@ #ifndef _GETRRSETBYNAME_H #define _GETRRSETBYNAME_H -#include "config.h" +#include "includes.h" #if defined(DNS) && !defined(HAVE_GETRRSETBYNAME) diff --git a/openbsd-compat/inet_aton.h b/openbsd-compat/inet_aton.h deleted file mode 100644 index 9b59cb908..000000000 --- a/openbsd-compat/inet_aton.h +++ /dev/null @@ -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 */ diff --git a/openbsd-compat/inet_ntoa.h b/openbsd-compat/inet_ntoa.h deleted file mode 100644 index 85bc3d6fe..000000000 --- a/openbsd-compat/inet_ntoa.h +++ /dev/null @@ -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 */ diff --git a/openbsd-compat/inet_ntop.h b/openbsd-compat/inet_ntop.h deleted file mode 100644 index c774df95c..000000000 --- a/openbsd-compat/inet_ntop.h +++ /dev/null @@ -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 */ diff --git a/openbsd-compat/mktemp.h b/openbsd-compat/mktemp.h deleted file mode 100644 index 505ca6a1f..000000000 --- a/openbsd-compat/mktemp.h +++ /dev/null @@ -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 */ diff --git a/openbsd-compat/openbsd-compat.h b/openbsd-compat/openbsd-compat.h index 76862cc8a..852948c54 100644 --- a/openbsd-compat/openbsd-compat.h +++ b/openbsd-compat/openbsd-compat.h @@ -1,5 +1,9 @@ +/* $Id: openbsd-compat.h,v 1.24 2003/08/29 16:59:52 mouring Exp $ */ + /* * Copyright (c) 1999-2003 Damien Miller. All rights reserved. + * Copyright (c) 2003 Ben Lindstrom. All rights reserved. + * Copyright (c) 2002 Tim Rice. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -22,45 +26,136 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* $Id: openbsd-compat.h,v 1.23 2003/06/11 12:51:32 djm Exp $ */ - -#ifndef _OPENBSD_H -#define _OPENBSD_H +#ifndef _OPENBSD_COMPAT_H +#define _OPENBSD_COMPAT_H -#include "config.h" +#include "includes.h" /* OpenBSD function replacements */ -#include "basename.h" -#include "bindresvport.h" -#include "getcwd.h" -#include "realpath.h" -#include "rresvport.h" -#include "strlcpy.h" -#include "strlcat.h" -#include "strmode.h" -#include "mktemp.h" -#include "daemon.h" -#include "dirname.h" #include "base64.h" #include "sigact.h" -#include "inet_ntoa.h" -#include "inet_ntop.h" -#include "strsep.h" -#include "setproctitle.h" -#include "getgrouplist.h" #include "glob.h" #include "readpassphrase.h" -#include "getopt.h" #include "vis.h" #include "getrrsetbyname.h" + +#ifndef HAVE_BASENAME +char *basename(const char *path); +#endif + +#ifndef HAVE_BINDRESVPORT_SA +int bindresvport_sa(int sd, struct sockaddr *sa); +#endif + +#ifndef HAVE_GETCWD +char *getcwd(char *pt, size_t size); +#endif + +#if !defined(HAVE_REALPATH) || defined(BROKEN_REALPATH) +char *realpath(const char *path, char *resolved); +#endif + +#ifndef HAVE_RRESVPORT_AF +int rresvport_af(int *alport, sa_family_t af); +#endif + +#ifndef HAVE_STRLCPY +/* #include XXX Still needed? */ +size_t strlcpy(char *dst, const char *src, size_t siz); +#endif + +#ifndef HAVE_STRLCAT +/* #include XXX Still needed? */ +size_t strlcat(char *dst, const char *src, size_t siz); +#endif + +#ifndef HAVE_SETENV +int setenv(register const char *name, register const char *value, int rewrite); +#endif + +#ifndef HAVE_STRMODE +void strmode(int mode, char *p); +#endif + +#if !defined(HAVE_MKDTEMP) || defined(HAVE_STRICT_MKSTEMP) +int mkstemps(char *path, int slen); +int mkstemp(char *path); +char *mkdtemp(char *path); +#endif + +#ifndef HAVE_DAEMON +int daemon(int nochdir, int noclose); +#endif + +#ifndef HAVE_DIRNAME +char *dirname(const char *path); +#endif + +#if defined(BROKEN_INET_NTOA) || !defined(HAVE_INET_NTOA) +char *inet_ntoa(struct in_addr in); +#endif + +#ifndef HAVE_INET_NTOP +const char *inet_ntop(int af, const void *src, char *dst, size_t size); +#endif + +#ifndef HAVE_INET_ATON +int inet_aton(const char *cp, struct in_addr *addr); +#endif + +#ifndef HAVE_STRSEP +char *strsep(char **stringp, const char *delim); +#endif + +#ifndef HAVE_SETPROCTITLE +void setproctitle(const char *fmt, ...); +void compat_init_setproctitle(int argc, char *argv[]); +#endif + +#ifndef HAVE_GETGROUPLIST +/* #include XXXX Still needed ? */ +int getgrouplist(const char *, gid_t, gid_t *, int *); +#endif + +#if !defined(HAVE_GETOPT) || !defined(HAVE_GETOPT_OPTRESET) +int BSDgetopt(int argc, char * const *argv, const char *opts); +#endif + + /* Home grown routines */ -#include "bsd-arc4random.h" -#include "bsd-getpeereid.h" #include "bsd-misc.h" -#include "bsd-snprintf.h" #include "bsd-waitpid.h" +/*#include XXX Still needed? * For uid_t, gid_t * */ + +#ifndef HAVE_GETPEEREID +int getpeereid(int , uid_t *, gid_t *); +#endif + +#ifndef HAVE_ARC4RANDOM +unsigned int arc4random(void); +void arc4random_stir(void); +#endif /* !HAVE_ARC4RANDOM */ + + + + +/* #include XXX needed? For size_t */ + +#ifndef HAVE_SNPRINTF +int snprintf(char *, size_t, const char *, ...); +#endif + +#ifndef HAVE_VSNPRINTF +int vsnprintf(char *, size_t, const char *, va_list); +#endif + +void *xmmap(size_t size); +char *xcrypt(const char *password, const char *salt); +char *shadow_pw(struct passwd *pw); + + /* rfc2553 socket API replacements */ #include "fake-rfc2553.h" @@ -70,4 +165,4 @@ #include "port-irix.h" #include "port-aix.h" -#endif /* _OPENBSD_H */ +#endif /* _OPENBSD_COMPAT_H */ diff --git a/openbsd-compat/port-aix.h b/openbsd-compat/port-aix.h index 16863ec6d..09e7f9e97 100644 --- a/openbsd-compat/port-aix.h +++ b/openbsd-compat/port-aix.h @@ -1,3 +1,5 @@ +/* $Id: port-aix.h,v 1.14 2003/08/29 16:59:52 mouring Exp $ */ + /* * * Copyright (c) 2001 Gert Doering. All rights reserved. @@ -21,7 +23,6 @@ * 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. - * */ #ifdef _AIX diff --git a/openbsd-compat/port-irix.h b/openbsd-compat/port-irix.h index bc8cc44ac..67c486307 100644 --- a/openbsd-compat/port-irix.h +++ b/openbsd-compat/port-irix.h @@ -1,3 +1,5 @@ +/* $Id: port-irix.h,v 1.4 2003/08/29 16:59:52 mouring Exp $ */ + /* * Copyright (c) 2000 Denis Parker. All rights reserved. * Copyright (c) 2000 Michael Stone. All rights reserved. diff --git a/openbsd-compat/realpath.h b/openbsd-compat/realpath.h deleted file mode 100644 index 25e4075d7..000000000 --- a/openbsd-compat/realpath.h +++ /dev/null @@ -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 */ diff --git a/openbsd-compat/rresvport.h b/openbsd-compat/rresvport.h deleted file mode 100644 index a52e4515b..000000000 --- a/openbsd-compat/rresvport.h +++ /dev/null @@ -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 */ diff --git a/openbsd-compat/setenv.h b/openbsd-compat/setenv.h deleted file mode 100644 index 77256d802..000000000 --- a/openbsd-compat/setenv.h +++ /dev/null @@ -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 */ diff --git a/openbsd-compat/setproctitle.h b/openbsd-compat/setproctitle.h deleted file mode 100644 index 48d26c6ea..000000000 --- a/openbsd-compat/setproctitle.h +++ /dev/null @@ -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 */ diff --git a/openbsd-compat/strlcat.h b/openbsd-compat/strlcat.h deleted file mode 100644 index 753668563..000000000 --- a/openbsd-compat/strlcat.h +++ /dev/null @@ -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 -size_t strlcat(char *dst, const char *src, size_t siz); -#endif /* !HAVE_STRLCAT */ - -#endif /* _BSD_STRLCAT_H */ diff --git a/openbsd-compat/strlcpy.h b/openbsd-compat/strlcpy.h deleted file mode 100644 index 3b137670d..000000000 --- a/openbsd-compat/strlcpy.h +++ /dev/null @@ -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 -size_t strlcpy(char *dst, const char *src, size_t siz); -#endif /* !HAVE_STRLCPY */ - -#endif /* _BSD_STRLCPY_H */ diff --git a/openbsd-compat/strmode.h b/openbsd-compat/strmode.h deleted file mode 100644 index 236ecf2f4..000000000 --- a/openbsd-compat/strmode.h +++ /dev/null @@ -1,7 +0,0 @@ -/* $Id: strmode.h,v 1.4 2003/08/25 01:10:52 mouring Exp $ */ - -#ifndef HAVE_STRMODE - -void strmode(int mode, char *p); - -#endif diff --git a/openbsd-compat/strsep.h b/openbsd-compat/strsep.h deleted file mode 100644 index 6ed810ac1..000000000 --- a/openbsd-compat/strsep.h +++ /dev/null @@ -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 */ diff --git a/openbsd-compat/vis.c b/openbsd-compat/vis.c index b8dd20226..e6a2ce98d 100644 --- a/openbsd-compat/vis.c +++ b/openbsd-compat/vis.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -#include "config.h" +#include "includes.h" #if !defined(HAVE_STRNVIS) #if defined(LIBC_SCCS) && !defined(lint) diff --git a/openbsd-compat/vis.h b/openbsd-compat/vis.h index 9a3365317..1c131cc85 100644 --- a/openbsd-compat/vis.h +++ b/openbsd-compat/vis.h @@ -32,7 +32,7 @@ * @(#)vis.h 5.9 (Berkeley) 4/3/91 */ -#include "config.h" +#include "includes.h" #if !defined(HAVE_STRNVIS) #ifndef _VIS_H_ diff --git a/openbsd-compat/xcrypt.h b/openbsd-compat/xcrypt.h deleted file mode 100644 index 16c55fc67..000000000 --- a/openbsd-compat/xcrypt.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2003 Ben Lindstrom. 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" - -char *xcrypt(const char *password, const char *salt); -char *shadow_pw(struct passwd *pw); diff --git a/openbsd-compat/xmmap.h b/openbsd-compat/xmmap.h deleted file mode 100644 index cae884060..000000000 --- a/openbsd-compat/xmmap.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2002 Tim Rice. 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: xmmap.h,v 1.2 2003/06/02 02:25:27 tim Exp $ */ - -void *xmmap(size_t size); -- cgit v1.2.3