Cant build "typespeed" in OS X :(

Discussion in 'Mac Programming' started by emil.s, Feb 7, 2007.

  1. emil.s macrumors newbie

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

    From its homesite:

    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:
    collect2: ld returned 1 exit status
    make: *** [typespeed] Error 1
    How did i solve this?
  2. iMeowbot macrumors G3


    Aug 30, 2003
    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);
    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.
  3. emil.s thread starter macrumors newbie

    Feb 7, 2007
  4. paldium macrumors newbie

    Feb 23, 2007

    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. :)

    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.

    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.
  5. iMeowbot macrumors G3


    Aug 30, 2003
    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").

    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).
    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).
  6. paldium macrumors newbie

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

    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.

    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.
  7. iMeowbot macrumors G3


    Aug 30, 2003
    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 :)

    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 :(

    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.
  8. paldium macrumors newbie

    Feb 23, 2007
    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:


    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. :)

Share This Page