Ported to OpenBSD

This commit is contained in:
Michiel Broek 2004-12-28 15:30:52 +00:00
parent d1603b8109
commit 2cec96dca1
17 changed files with 47 additions and 37 deletions

View File

@ -341,6 +341,8 @@ char *OsName()
return (char *)"FreeBSD";
#elif __NetBSD__
return (char *)"NetBSD";
#elif __OpenBSD__
return (char *)"OpenBSD";
#else
return (char *)"Unknown";
#endif

View File

@ -32,7 +32,7 @@
#include "../lib/mbselib.h"
#ifndef LOCKDIR
#if defined(__FreeBSD__) || defined(__NetBSD__)
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#define LOCKDIR "/var/spool/lock"
#else
#define LOCKDIR "/var/lock"

View File

@ -412,6 +412,8 @@ void soft_info(void)
p = xstrcpy((char *)"MBSE BBS (FreeBSD");
#elif __NetBSD__
p = xstrcpy((char *)"MBSE BBS (NetBSD");
#elif __OpenBSD__
p = xstrcpy((char *)"MBSE BBS (OpenBSD");
#else
p = xstrcpy((char *)"MBSE BBS (Unknown");
#endif

View File

@ -106,6 +106,9 @@ int CountTtyinfo(void)
#endif
#ifdef __NetBSD__
sprintf(ttyinfo.tty, "ttyi%c", i + 'a'); // NetBSD on a Sparc, how about PC's?
#endif
#ifdef __OpenBSD__
sprintf(ttyinfo.tty, "cuaia%d", i); // I think this is wrong!
#endif
sprintf(ttyinfo.speed, "64 kbits");
sprintf(ttyinfo.flags, "XA,X75,CM");
@ -128,6 +131,9 @@ int CountTtyinfo(void)
#endif
#ifdef __NetBSD__
sprintf(ttyinfo.tty, "tty%c", i + 'a'); // NetBSD on a Sparc, how about PC's?
#endif
#ifdef __OpenBSD__
sprintf(ttyinfo.tty, "tty0%d", i);
#endif
sprintf(ttyinfo.speed, "33.6 kbits");
sprintf(ttyinfo.flags, "CM,XA,V32B,V42B,V34");

View File

@ -1075,7 +1075,7 @@ void *scheduler(void)
* Check the systems load average.
*/
Load = loadavg[0] = loadavg[1] = loadavg[2] = 0.0;
#if defined(__FreeBSD__) || defined(__NetBSD__)
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
if (getloadavg(loadavg, 3) == 3) {
Load = loadavg[0];
}

View File

@ -62,7 +62,7 @@ int ping_receive(struct in_addr);
/*
* different names, same thing... be careful, as these are macros...
*/
#if defined(__FreeBSD__) || defined(__NetBSD__)
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
# define icmphdr icmp
# define iphdr ip
# define ip_saddr ip_src.s_addr
@ -89,7 +89,7 @@ int ping_receive(struct in_addr);
# define icmp_seq un.echo.sequence
#endif
#if defined(__FreeBSD__) || defined(__NetBSD__)
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
# define ICMP_DEST_UNREACH ICMP_UNREACH
# define ICMP_TIME_EXCEEDED ICMP_TIMXCEED
#endif

View File

@ -36,7 +36,7 @@
#ifndef LOCKDIR
#if defined(__FreeBSD__) || defined(__NetBSD__)
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#define LOCKDIR "/var/spool/lock"
#else
#define LOCKDIR "/var/lock"

View File

@ -358,7 +358,7 @@ void update_diskstat(void)
* See man 2 statvfs about what approximately is defined.
*/
tmp->ro = (strstr(tmp->fstype, "iso") != NULL);
#elif defined(__FreeBSD__) || defined(__NetBSD__)
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
/*
* XxxxBSD has the info in the statfs structure.
*/
@ -381,7 +381,7 @@ void add_path(char *lpath)
#if defined(__linux__)
char *mtab, *fs;
FILE *fp;
#elif defined(__FreeBSD__) || defined(__NetBSD__)
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
struct statfs *mntbuf;
long mntsize;
int i;
@ -432,7 +432,7 @@ void add_path(char *lpath)
fill_mfslist(&mfs, fsname, fstype);
}
#elif defined(__FreeBSD__) || defined(__NetBSD__)
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT))) {
@ -446,7 +446,7 @@ void add_path(char *lpath)
}
#else
#error "Unknow OS - don't know what to do"
#error "Unknown OS - don't know what to do"
#endif
} else {

View File

@ -213,7 +213,7 @@ int execute(char **args, char *in, char *out, char *err)
#if !defined(__FreeBSD__) && !defined(__NetBSD__)
#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__)
static void fail_exit(int status)
{
// gr_unlock();
@ -627,7 +627,7 @@ static int new_password(const struct passwd *pw, char *newpasswd)
}
#if !defined(__FreeBSD__) && !defined(__NetBSD__)
#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__)
static void update_noshadow(int shadow_locked)
{
@ -751,7 +751,7 @@ static void update_noshadow(int shadow_locked)
pw_unlock();
}
#endif /* Not __FreeBSD__ && __NetBSD__ */
#endif /* Not __FreeBSD__ && __NetBSD__ && __OpenBSD__ */
#ifdef SHADOW_PASSWORD
@ -815,7 +815,7 @@ static void update_shadow(void)
*/
int main(int argc, char *argv[])
{
#if !defined(__FreeBSD__) && !defined(__NetBSD__)
#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__)
const struct passwd *pw;
const struct group *gr;
#ifdef SHADOW_PASSWORD
@ -971,7 +971,7 @@ int main(int argc, char *argv[])
* to root to protect against unexpected signals. Any
* keyboard signals are set to be ignored.
*/
#if !defined(__FreeBSD__) && !defined(__NetBSD__)
#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__)
pwd_init();
#else
pw_init();
@ -985,7 +985,7 @@ int main(int argc, char *argv[])
exit(E_FAILURE);
}
#if !defined(__FreeBSD__) && !defined(__NetBSD__)
#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__)
#ifdef HAVE_USERSEC_H
update_userpw(pw->pw_passwd);
@ -999,7 +999,7 @@ int main(int argc, char *argv[])
update_noshadow(0);
#endif /* !HAVE_USERSEC_H */
#else /* __FreeBSD__ && __NetBSD__ */
#else /* __FreeBSD__ && __NetBSD__ && __OpenBSD__ */
/*
* FreeBSD password change, borrowed from the original FreeBSD sources
*/
@ -1018,7 +1018,7 @@ int main(int argc, char *argv[])
if (!pw_mkdb(pw->pw_name))
pw_error((char *)NULL, 0, 1);
#endif /* __FreeBSD__ */
#endif /* __FreeBSD__ && __NetBSD__ && __OpenBSD__ */
#ifdef _VPOPMAIL_PATH
fflush(stdout);

View File

@ -30,7 +30,7 @@ char *crypt_make_salt(void);
char *pw_encrypt(const char *, const char *);
int i64c(int);
char *l64a(long);
#if !defined(__FreeBSD__) && !defined(__NetBSD__)
#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__)
static void fail_exit(int);
static void oom(void);
static void update_noshadow(int);

View File

@ -198,7 +198,7 @@ int main(int argc, char *argv[])
* Build command to add user entry to the /etc/passwd and /etc/shadow
* files. We use the systems own useradd program.
*/
#if defined(__linux__) || defined(__NetBSD__)
#if defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__)
if ((access("/usr/bin/useradd", R_OK)) == 0)
args[0] = (char *)"/usr/bin/useradd";
else if ((access("/bin/useradd", R_OK)) == 0)
@ -240,7 +240,7 @@ int main(int argc, char *argv[])
args[9] = argv[2];
args[10] = NULL;
#endif
#if defined(__NetBSD__)
#if defined(__NetBSD__) || defined(__OpenBSD__)
args[1] = (char *)"-c";
args[2] = argv[3];
args[3] = (char *)"-d";

View File

@ -62,7 +62,7 @@
* SUCH DAMAGE.
*/
#if defined(__FreeBSD__) || defined(__NetBSD__)
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#include "../config.h"
#include <sys/param.h>
@ -196,12 +196,12 @@ int pw_mkdb(char *username)
execl(_PATH_PWD_MKDB, "pwd_mkdb", "-p", tempname, NULL);
} else {
syslog(LOG_WARNING, "updating the database for %s...", username);
#ifdef __FreeBSD__
#if defined(__FreeBSD__) || defined(__OpenBSD__)
execl(_PATH_PWD_MKDB, "pwd_mkdb", "-p", "-u", username, tempname, NULL);
#elif __NetBSD__
#elif defined(__NetBSD__)
execl(_PATH_PWD_MKDB, "pwd_mkdb", "-p", tempname, NULL);
#else
#error "Not FreeBSD or NetBSD - don't know what to do"
#error "Not FreeBSD, OpenBSD or NetBSD - don't know what to do"
#endif
}
pw_error((char *)_PATH_PWD_MKDB, 1, 1);
@ -285,7 +285,7 @@ void pw_copy(int ffd, int tfd, struct passwd *pw)
goto err;
continue;
}
#ifdef __FreeBSD__
#if defined(__FreeBSD__)
(void)fprintf(to, "%s:%s:%s:%s:%s:%s:%s:%s:%s:%s\n",
pw->pw_name, pw->pw_passwd,
pw->pw_fields & _PWF_UID ? uidstr : "",
@ -294,7 +294,7 @@ void pw_copy(int ffd, int tfd, struct passwd *pw)
pw->pw_fields & _PWF_CHANGE ? chgstr : "",
pw->pw_fields & _PWF_EXPIRE ? expstr : "",
pw->pw_gecos, pw->pw_dir, pw->pw_shell);
#elif __NetBSD__
#elif defined(__NetBSD__) || defined(__OpenBSD__)
(void)fprintf(to, "%s:%s:%s:%s:%s:%s:%s:%s:%s:%s\n",
pw->pw_name, pw->pw_passwd,
uidstr, gidstr,
@ -302,7 +302,7 @@ void pw_copy(int ffd, int tfd, struct passwd *pw)
chgstr, expstr,
pw->pw_gecos, pw->pw_dir, pw->pw_shell);
#else
#error "Not FreeBSD or NetBSD - don't know what to do"
#error "Not FreeBSD, OpenBSD or NetBSD - don't know what to do"
#endif
done = 1;
if (ferror(to))
@ -317,7 +317,7 @@ void pw_copy(int ffd, int tfd, struct passwd *pw)
pw_error(NULL, 0, 1);
} else
#endif /* YP */
#ifdef __FreeBSD__
#if defined(__FreeBSD__)
(void)fprintf(to, "%s:%s:%s:%s:%s:%s:%s:%s:%s:%s\n",
pw->pw_name, pw->pw_passwd,
pw->pw_fields & _PWF_UID ? uidstr : "",
@ -326,7 +326,7 @@ void pw_copy(int ffd, int tfd, struct passwd *pw)
pw->pw_fields & _PWF_CHANGE ? chgstr : "",
pw->pw_fields & _PWF_EXPIRE ? expstr : "",
pw->pw_gecos, pw->pw_dir, pw->pw_shell);
#elif __NetBSD__
#elif defined(__NetBSD__) || defined(__OpenBSD__)
(void)fprintf(to, "%s:%s:%s:%s:%s:%s:%s:%s:%s:%s\n",
pw->pw_name, pw->pw_passwd,
uidstr, gidstr,
@ -334,7 +334,7 @@ void pw_copy(int ffd, int tfd, struct passwd *pw)
chgstr, expstr,
pw->pw_gecos, pw->pw_dir, pw->pw_shell);
#else
#error "Not FreeBSD or NetBSD - don't know what to do"
#error "Not FreeBSD, OpenBSD or NetBSD - don't know what to do"
#endif
}

View File

@ -37,7 +37,7 @@
#ifndef _PW_UTIL_H
#define _PW_UTIL_H
#if defined(__FreeBSD__) || defined(__NetBSD__)
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
void pw_error __P((char *, int, int));
void pw_init __P((void));

View File

@ -30,7 +30,7 @@
* Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*****************************************************************************/
#if !defined(__FreeBSD__) && !defined(__NetBSD__)
#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__)
#include "../config.h"
#include <stdio.h>
@ -168,7 +168,7 @@ int pw_name(const char *filename)
#if !defined(__FreeBSD__) && !defined(__NetBSD__)
#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__)
int pw_lock(void)
{
return commonio_lock(&passwd_db);

View File

@ -3,7 +3,7 @@
#ifndef _PWIO_H
#define _PWIO_H
#if !defined(__FreeBSD__) && !defined(__NetBSD__)
#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__)
#ifndef PASSWD_FILE
#define PASSWD_FILE "/etc/passwd"

View File

@ -398,10 +398,10 @@ void setutmp(const char *name, const char *line, const char *host)
utent = utline;
}
#elif __FreeBSD__ || __NetBSD__
#elif __FreeBSD__ || __NetBSD__ || __OpenBSD__
/*
* FreeBSD/NetBSD version, simple and mean.
* FreeBSD/NetBSD/OpenBSD version, simple and mean.
*/
void setutmp(const char *name, const char *line, const char *host)
{

View File

@ -20,7 +20,7 @@ static void updwtmpx(const char *, const struct utmpx *);
void setutmp(const char *, const char *, const char *);
#elif HAVE_UTMPX_H
void setutmp(const char *, const char *, const char *);
#elif __FreeBSD__ || __NetBSD__
#elif __FreeBSD__ || __NetBSD__ || __OpenBSD__
void setutmp(const char *, const char *, const char *);
#else /* !SVR4 */
void setutmp(const char *, const char *);