PDA

View Full Version : Cant build "typespeed" in OS X :(




emil.s
Feb 8, 2007, 01:42 AM
OS X is not supported. But both Linux and *BSD supports it, så i think it should be possible :)

From its homesite:
Generally any POSIX-compatible system with a curses library and some advanced functions (like snprintf(), etc.) should work, although development concentrates on GNU/Linux (i386) and ncurses. Feel free to contribute patches for your system, too! Beside of that the following systems have been tested and/or have maintained ports:

* Arch Linux
* Cygwin
* Debian GNU/Linux
* FreeBSD
* Gentoo Linux
* OpenBSD
http://tobias.eyedacor.org/typespeed/

I have installed "ncurses", and "binutils" from DarwinPorts. But i get this error when i try to compile it:
emil@emils-macbook.local: ~/Desktop/typespeed-0.6.0 $ make
gcc file.o menu.o misc.o network.o typespeed.o \
-o typespeed -lncurses
/usr/bin/ld: Undefined symbols:
_setresgid
collect2: ld returned 1 exit status
make: *** [typespeed] Error 1

How did i solve this?



iMeowbot
Feb 8, 2007, 02:04 AM
Let's skip the Darwinports stuff and use the stock Mac libraries.

Here is what will make typespeed 0.6.0 compile, and get it installed and running.

It might not be a bad idea to make a new group for games, because this thing uses setuid for high scores, which is just plain evil for a game.

Anyway, the source code needs a patch, because OS X doesn't do setresgid. On about line 265 of typespeed.c, change the line:
setresgid(gid, gid, gid);
to:
setgid(gid);
setegid(gid);


Now make should build the program.

You will need to create a directory (with sudo) called /usr/local/var/games and copy typespeed.score there. Then, chmod 664 /usr/local/var/games/typespeed.score

You will then need to copy typespeed itself somewhere (make /usr/local/bin if you don't already have one), and then chmod 2755 /usr/local/bin/typespeed

Finally, try sudo make install -- it will display some errors but that's kay because we took care of that part already.

You'll next need to do a little more cleanup for the broken install: sudo cp words/* /usr/local/share/typespeed/words/

At that point, /usr/local/bin/typespeed should let you play.

emil.s
Feb 8, 2007, 02:31 AM
Thanks! It works perfect!
Thanks once again! :D

paldium
Feb 23, 2007, 01:20 PM
Hi,

I just found this site while searching for any security/bug reports about typespeed with google. The past has shown that a maintainer/developer won't be contacted too often when problems arise, so I had to switch over to this active role. :)

It might not be a bad idea to make a new group for games, because this thing uses setuid for high scores, which is just plain evil for a game.

The setuid is actualy a setgid and it should be group games as you wrote. This step is necessary to be able to create a system-wide high score file for all users. I took a look at other games and found out that this is normal behaviour, but I have no problem to implement a better solution than setuid/setgid. Suggestions are welcome.

Finally, try sudo make install -- it will display some errors but that's kay because we took care of that part already.

Can you post all error messages during make and make install (or mail me), please? I am curious what is wrong for Mac OS X.

iMeowbot
Feb 25, 2007, 10:17 AM
I just found this site while searching for any security/bug reports about typespeed with google. The past has shown that a maintainer/developer won't be contacted too often when problems arise, so I had to switch over to this active role. :)
Okay, fair enough. As soon as I saw Linuxisms in the source code, I had figured that portability wasn't of much interest (that's not from anything you've said, just from past experience with other projects that took "runs on Linux" as "done").

The setuid is actualy a setgid and it should be group games as you wrote. This step is necessary to be able to create a system-wide high score file for all users. I took a look at other games and found out that this is normal behaviour, but I have no problem to implement a better solution than setuid/setgid. Suggestions are welcome.
setgid is okay conceptually, but for safety such things should be walled off into their own little helper programs. The game proper should be happy to run without elevated privileges, let it call a small command-line helper that records high scores (and does nothing else). Having the privs of a games group should keep the stakes pretty low anyway, but the separation will buy peace of mind on nonstandard installations (and in environments like Cygwin where privileges don't really map so cleanly to their unixy counterparts).
Can you post all error messages during make and make install (or mail me), please? I am curious what is wrong for Mac OS X.
The problem there is a simple one, the makefile assumes GNU install. OS X comes with BSD install, a whole different animal.

One weird OSX-ism is the creation of groups. Once they exist they work in the usual Unixy way, but a simple addition to /etc/group is usually the Wrong Thing. Instead the wild and wacky netinfo database is usually used (not hard to use, but it differes from the rest of the world).

paldium
Mar 2, 2007, 08:38 AM
setgid(gid);
setegid(gid);


I thought setgid is a superset of setegid, i.e. setting real and effective group IDs. Why do you call setegid right after setgid?

The problem there is a simple one, the makefile assumes GNU install. OS X comes with BSD install, a whole different animal.

Strange, I thought Mac OS X's install would be the same as FreeBSD's or OpenBSD's (which I tested). Anyway, I switched to autotools which should do it the right way.

setgid is okay conceptually, but for safety such things should be walled off into their own little helper programs.

I think about this for later typespeed versions. Another possibility without adding new binaries would be a configure-option to prevent setgid and system wide high scores. Or even better: you need a configure option to enable setgid. A package maintainer should know how to use it, anyway.

iMeowbot
Mar 2, 2007, 09:10 AM
I thought setgid is a superset of setegid, i.e. setting real and effective group IDs. Why do you call setegid right after setgid?
Only because that's what the setresgid() it replaced does (the "saved" concept doesn't translate over). It's redundant redundancy, but that's what was there already :)

Strange, I thought Mac OS X's install would be the same as FreeBSD's or OpenBSD's (which I tested). Anyway, I switched to autotools which should do it the right way.
Yep, in some areas OS X is more of a traditional BSD than FreeBSD is these days.

Lots of people fall into this trap, because the story that OS X is "based on FreeBSD" is so widely circulated, probably in part because Jordan Hubbard went over to Apple. Apple did borrow lots of code from other branches of the BSD family, but they diverge fairly dramatically in many areas :(

I think about this for later typespeed versions. Another possibility without adding new binaries would be a configure-option to prevent setgid and system wide high scores. Or even better: you need a configure option to enable setgid. A package maintainer should know how to use it, anyway.
Again, the games group is a pretty low stake in the scheme of things, so it's not exactly a critical worry. Other possibilities would be a separate account or group for the game (effectively restricting its potential access to only that one file), or for the configuration option to make high scores a per-user thing.

paldium
Mar 3, 2007, 06:30 AM
I modified typespeed source to use setgid(). It seems that this does the right thing on most (or at least on tested) systems. Perhaps someone would like to test this new snapshot for Mac OS X:

typespeed-0.6.0-20070303.tar.gz (http://paldium.homeunix.org/tobias/typespeed/typespeed-0.6.0-20070303.tar.gz)

Apple did borrow lots of code from other branches of the BSD family, but they diverge fairly dramatically in many areas :(

I only had access to a Mac OS X system during school. Once I took a look at all binaries I found with "strings -a $file | grep BSD". I was realy surprised how many binaries have been mixed in there. :)