From 2cec96dca1b5f9d8704da5817185dcb4b74800a2 Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Tue, 28 Dec 2004 15:30:52 +0000 Subject: [PATCH] Ported to OpenBSD --- lib/strutil.c | 2 ++ mbcico/ulock.c | 2 +- mbmon/mbmon.c | 2 ++ mbsetup/m_tty.c | 6 ++++++ mbtask/mbtask.c | 2 +- mbtask/ping.c | 4 ++-- mbtask/ports.c | 2 +- mbtask/taskdisk.c | 8 ++++---- unix/mbpasswd.c | 16 ++++++++-------- unix/mbpasswd.h | 2 +- unix/mbuseradd.c | 4 ++-- unix/pw_util.c | 20 ++++++++++---------- unix/pw_util.h | 2 +- unix/pwio.c | 4 ++-- unix/pwio.h | 2 +- unix/utmp.c | 4 ++-- unix/utmp.h | 2 +- 17 files changed, 47 insertions(+), 37 deletions(-) diff --git a/lib/strutil.c b/lib/strutil.c index d18289c7..ade4062a 100644 --- a/lib/strutil.c +++ b/lib/strutil.c @@ -341,6 +341,8 @@ char *OsName() return (char *)"FreeBSD"; #elif __NetBSD__ return (char *)"NetBSD"; +#elif __OpenBSD__ + return (char *)"OpenBSD"; #else return (char *)"Unknown"; #endif diff --git a/mbcico/ulock.c b/mbcico/ulock.c index 38b4eea3..733b65af 100644 --- a/mbcico/ulock.c +++ b/mbcico/ulock.c @@ -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" diff --git a/mbmon/mbmon.c b/mbmon/mbmon.c index 32a0d789..1a5ca2d8 100644 --- a/mbmon/mbmon.c +++ b/mbmon/mbmon.c @@ -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 diff --git a/mbsetup/m_tty.c b/mbsetup/m_tty.c index 2194d8b1..e3e848e0 100644 --- a/mbsetup/m_tty.c +++ b/mbsetup/m_tty.c @@ -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"); diff --git a/mbtask/mbtask.c b/mbtask/mbtask.c index 5e15278e..b0775767 100644 --- a/mbtask/mbtask.c +++ b/mbtask/mbtask.c @@ -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]; } diff --git a/mbtask/ping.c b/mbtask/ping.c index 97483aaa..62cbfe82 100644 --- a/mbtask/ping.c +++ b/mbtask/ping.c @@ -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 diff --git a/mbtask/ports.c b/mbtask/ports.c index b1561e7d..ba85f7e6 100644 --- a/mbtask/ports.c +++ b/mbtask/ports.c @@ -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" diff --git a/mbtask/taskdisk.c b/mbtask/taskdisk.c index 7a1c5ea6..4010e5b3 100644 --- a/mbtask/taskdisk.c +++ b/mbtask/taskdisk.c @@ -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 { diff --git a/unix/mbpasswd.c b/unix/mbpasswd.c index 85a81877..d5c5d340 100644 --- a/unix/mbpasswd.c +++ b/unix/mbpasswd.c @@ -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); diff --git a/unix/mbpasswd.h b/unix/mbpasswd.h index b95d8487..cb05c3a8 100644 --- a/unix/mbpasswd.h +++ b/unix/mbpasswd.h @@ -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); diff --git a/unix/mbuseradd.c b/unix/mbuseradd.c index ccbca778..ae9dae06 100644 --- a/unix/mbuseradd.c +++ b/unix/mbuseradd.c @@ -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"; diff --git a/unix/pw_util.c b/unix/pw_util.c index 867e4a0f..b20be3cb 100644 --- a/unix/pw_util.c +++ b/unix/pw_util.c @@ -62,7 +62,7 @@ * SUCH DAMAGE. */ -#if defined(__FreeBSD__) || defined(__NetBSD__) +#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) #include "../config.h" #include @@ -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 } diff --git a/unix/pw_util.h b/unix/pw_util.h index 935aa7b3..072e1cc2 100644 --- a/unix/pw_util.h +++ b/unix/pw_util.h @@ -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)); diff --git a/unix/pwio.c b/unix/pwio.c index e3a31be1..1e5b31de 100644 --- a/unix/pwio.c +++ b/unix/pwio.c @@ -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 @@ -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); diff --git a/unix/pwio.h b/unix/pwio.h index af736805..e035f8f6 100644 --- a/unix/pwio.h +++ b/unix/pwio.h @@ -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" diff --git a/unix/utmp.c b/unix/utmp.c index b62ae954..10be6055 100644 --- a/unix/utmp.c +++ b/unix/utmp.c @@ -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) { diff --git a/unix/utmp.h b/unix/utmp.h index d6a52e34..9352fb5c 100644 --- a/unix/utmp.h +++ b/unix/utmp.h @@ -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 *);