- Make it compile on operating systems other than BSD due to OpenBSD patchset

308.
- While there, remove some duplicate code from the compat header file.
pull/1/head
Tiago Cunha 2009-09-03 20:54:39 +00:00
parent f796336a12
commit c274551db6
3 changed files with 22 additions and 55 deletions

View File

@ -1,4 +1,4 @@
/* $Id: compat.h,v 1.16 2009-09-02 12:30:56 nicm Exp $ */
/* $Id: compat.h,v 1.17 2009-09-03 20:54:39 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -91,6 +91,10 @@ typedef uint64_t u_int64_t;
#include "compat/imsg.h"
#endif
#ifdef HAVE_LOGIN_CAP
#include <login_cap.h>
#endif
#ifdef HAVE_BROKEN_CMSG_FIRSTHDR
/* Broken on OS X. */
#undef CMSG_FIRSTHDR
@ -146,6 +150,10 @@ typedef uint64_t u_int64_t;
#define TTY_NAME_MAX 32
#endif
#ifndef _PW_BUF_LEN
#define _PW_BUF_LEN 1024
#endif
#ifndef HAVE_BZERO
#define bzero(buf, len) memset((buf), 0, (len));
#endif
@ -211,54 +219,3 @@ int BSDgetopt(int, char *const *, const char *);
#define optreset BSDoptreset
#define optarg BSDoptarg
#endif
#ifndef HAVE_STRTONUM
/* strtonum.c */
long long strtonum(const char *, long long, long long, const char **);
#endif
#ifndef HAVE_STRLCPY
/* strlcpy.c */
size_t strlcpy(char *, const char *, size_t);
#endif
#ifndef HAVE_STRLCAT
/* strlcat.c */
size_t strlcat(char *, const char *, size_t);
#endif
#ifndef HAVE_DAEMON
/* daemon.c */
int daemon(int, int);
#endif
#ifndef HAVE_FORKPTY
/* forkpty.c */
pid_t forkpty(int *, char *, struct termios *, struct winsize *);
#endif
#ifndef HAVE_ASPRINTF
/* asprintf.c */
int asprintf(char **, const char *, ...);
int vasprintf(char **, const char *, va_list);
#endif
#ifndef HAVE_FGETLN
/* fgetln.c */
char *fgetln(FILE *, size_t *);
#endif
#ifndef HAVE_GETOPT
/* getopt.c */
extern int BSDopterr;
extern int BSDoptind;
extern int BSDoptopt;
extern int BSDoptreset;
extern char *BSDoptarg;
int BSDgetopt(int, char *const *, const char *);
#define getopt(ac, av, o) BSDgetopt(ac, av, o)
#define opterr BSDopterr
#define optind BSDoptind
#define optopt BSDoptopt
#define optreset BSDoptreset
#define optarg BSDoptarg
#endif

6
configure vendored
View File

@ -1,5 +1,5 @@
#!/bin/sh
# $Id: configure,v 1.34 2009-09-02 12:30:56 nicm Exp $
# $Id: configure,v 1.35 2009-09-03 20:54:39 tcunha Exp $
TMUX_PLATFORM=${TMUX_PLATFORM:-`uname -s`}
@ -22,6 +22,7 @@ cat <<EOF >>$CONFIG_H
#undef HAVE_GETOPT
#undef HAVE_IMSG
#undef HAVE_LIBUTIL_H
#undef HAVE_LOGIN_CAP
#undef HAVE_PATHS_H
#undef HAVE_POLL
#undef HAVE_PROGNAME
@ -52,6 +53,7 @@ case $TMUX_PLATFORM in
#define HAVE_FGETLN
#define HAVE_FORKPTY
#define HAVE_GETOPT
#define HAVE_LOGIN_CAP
#define HAVE_PATHS_H
#define HAVE_POLL
#define HAVE_PROGNAME
@ -207,6 +209,7 @@ EOF
#define HAVE_FORKPTY
#define HAVE_GETOPT
#define HAVE_LIBUTIL_H
#define HAVE_LOGIN_CAP
#define HAVE_PATHS_H
#define HAVE_POLL
#define HAVE_PROGNAME
@ -238,6 +241,7 @@ EOF
#define HAVE_FGETLN
#define HAVE_FORKPTY
#define HAVE_GETOPT
#define HAVE_LOGIN_CAP
#define HAVE_PATHS_H
#define HAVE_POLL
#define HAVE_PROGNAME

View File

@ -1,4 +1,4 @@
/* $Id: server-fn.c,v 1.84 2009-09-03 20:44:38 tcunha Exp $ */
/* $Id: server-fn.c,v 1.85 2009-09-03 20:54:39 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -18,7 +18,6 @@
#include <sys/types.h>
#include <login_cap.h>
#include <pwd.h>
#include <string.h>
#include <time.h>
@ -199,7 +198,9 @@ int
server_unlock(const char *s)
{
struct client *c;
#ifdef HAVE_LOGIN_CAP
login_cap_t *lc;
#endif
u_int i;
char *out;
u_int failures, tries, backoff;
@ -250,6 +251,7 @@ wrong:
* Start slowing down after "login-backoff" attempts and reset every
* "login-tries" attempts.
*/
#ifdef HAVE_LOGIN_CAP
lc = login_getclass(server_locked_pw->pw_class);
if (lc != NULL) {
tries = login_getcapnum(lc, (char *) "login-tries", 10, 10);
@ -258,6 +260,10 @@ wrong:
tries = 10;
backoff = 3;
}
#else
tries = 10;
backoff = 3;
#endif
failures = password_failures % tries;
if (failures > backoff) {
password_backoff += ((failures - backoff) * tries / 2);